Skip to main content
Module

x/cookie_driver/mod.ts>CookieDB

A fast and correct cookiedb driver for esm platforms
Latest
class CookieDB
import { CookieDB } from "https://deno.land/x/cookie_driver@0.5.1/mod.ts";

Main CookieDB interface

Constructors

new
CookieDB(url: string, auth: string)

Properties

auth: string
url: string

Methods

createTable(table: string, schema?: Schema)

Create a table by name and with an optional schema

createUser(options?: { username?: string; token?: string; admin?: boolean; }): Promise<{ username: string; token: string; }>

Creates a user for this database. Requires an administrator token.

delete(table: string, key: string)

Delete a document from table by key.

deleteByQuery(table: string, query: string): Promise<string[]>

Delete documents from table by query.

deleteUser(username: string)

Deletes a user for this database. Requires an administrator token.

dropTable(table: string)

Drops a table by name

editTable(table: string, opts: { name?: string; schema?: Schema; alias?: Alias; })

Edit a table by name

get<T>(
table: string,
key: string,
expandKeys?: boolean,
): Promise<T>

Get a document from table by key. Optionally can join documents by foreign keys

insert<T>(table: string, document: T): Promise<T extends Array<T> ? string[] : string>

Insert a document into a table and return key

meta(): Promise<{ tables: Record<string, { schema: Schema; }>; size: number; }>

Gets metadata for all tables for this user

metaTable(table: string): Promise<{ schema: Schema; size: number; }>

Gets metadata for a table by name

regenerateToken(username: string)

Regenerates a token for a user for this database. Requires an administrator token.

select<T>(
table: string,
where?: string,
options?: { maxResults?: number; expandKeys?: boolean; alias?: Alias; order?: { by: string; descending?: boolean; }; },
): Promise<T[]>

Selects a number of documents from a table. Accepts an options argument that specifies the maximum amount of results, whether to display keys, and whether to join documents by foreign keys.

update(
table: string,
key: string,
document: Document,
)

Update a document from table by key.