Skip to main content
Module

x/cookie_driver/mod.ts>CookieDB

A fast and correct cookiedb driver for esm platforms
Go to Latest
class CookieDB
import { CookieDB } from "https://deno.land/x/cookie_driver@0.3.0/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.

deleteUser(username: string)

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

dropTable(table: string)

Drops a table by name

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

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

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

Insert a document into a table and return key

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

Gets metadata for all tables for this user

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

Gets metadata for a table by name

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

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.