Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

default

import { default } from "https://7smzlzo4lz2ivy7dcfbyll4asdkqtc62pbdit23ysj5xdlu6wsra.arweave.net/_JmV5dxedIrj4xFDha-AkNUJi9p4RonreJJ7ca6etKI/mod.ts";

the Model skeleton to be controlled at collection

interface default {
createdAt?: Date;
id?: string;
updatedAt?: Date;
}
class default {
constructor(rootDir?: string, dbOptions?: FileDBOptions);
private autosave: boolean;
private collections: Record<string, Collection>;
private rootDir: string;
 
getCollection<T extends Document>(colName: string): Collection<T>;
getCollectionNames();
save();
 
static drop(rootDir: string);
}
class default<T extends Document = Document> {
constructor(name: string, collectionOptions: CollectionOptions);
private autosave: boolean;
private data: T[];
private fsPath: string;
 
deleteMany(options: T);
deleteOne(options: T);
find(options: T);
findOne(options: T);
insertMany(els: T[]);
insertOne(el: T);
save();
updateMany(options: T, el: T);
updateOne(options: T, el: T);
}

§Properties

§
createdAt?: Date
[src]
§
id?: string
[src]
§
updatedAt?: Date
[src]

§Constructors

§
new default(rootDir?: string, dbOptions?: FileDBOptions)
[src]

Ensure the data folder is existed.

@param rootDir

Optional: the base url of the data folder, default "./db"

§Properties

§
autosave: boolean
[src]
§
collections: Record<string, Collection>
[src]
§
rootDir: string
[src]

§Methods

§
getCollection<T extends Document>(colName: string): Collection<T>
[src]

Get a collection

@param colName

Collection Name

@template T

a type extending Collection Model

@return

the specified collection

§
getCollectionNames()
[src]

Get all collection names

@return

an array containing collection names

§
save()
[src]

Save all data of all collections

§Static Methods

§
drop(rootDir: string)
[src]

Drop a database with the given path

@param rootDir

root directory of the database

§Type Parameters

§Constructors

§
new default(name: string, collectionOptions: CollectionOptions)
[src]

Ensure the collection file is existed. Read the initial data from the file if the file existed.

@param name

the Collection name

@param collectionOptions

§Properties

§
autosave: boolean
[src]
§
data: T[]
[src]
§
fsPath: string
[src]

§Methods

§
deleteMany(options: T)
[src]

Bulk delete

@param options

Filter conditions of documents

@return

the deleted document IDs

§
deleteOne(options: T)
[src]

Delete a document

@param options

Filter conditions of documents

@return

the deleted document ID

§
find(options: T)
[src]

Find some documents by using filter conditions

Caution! The method on this stage is only able to find documents with equals properties. For more options like greater than, less than or equal to, please wait for newer version

@param options

filter conditions

@return

the filtered documents

§
findOne(options: T)
[src]
§
insertMany(els: T[])
[src]

Bulk Insert

@param els

an array of documents to be inserted

@return

the inserted documents

§
insertOne(el: T)
[src]

Insert a document

@param el

the document to be inserted

@return

the inserted document

§
save()
[src]

Save a copy of the data snapshot at this point to the file.

§
updateMany(options: T, el: T)
[src]

Bulk Update

@param options

filter condition of documents

@param el

the updated document attributes

@return

the updated documents

§
updateOne(options: T, el: T)
[src]

Update a document

@param options

filter condition of documents

@param el

the updated document attributes

@return

the updated document