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

Collection

import { Collection } from "https://pk2kfdkzhspesdc7wayhxkmyv4eoyh7wkpzlhylcq3fga5gelt7q.arweave.net/erSijVk8nkkMX7Awe6mYrwjsH_ZT8rPhYobKYHTEXP8/mod.ts";
class Collection<T extends Model = Model> {
constructor(name: string, baseUrl: string);
private data: T[];
private fsPath: string;
 
delete(id?: string);
find(options: T);
get();
getById(id: string);
insert(el: T);
save();
update(id: string, el: T);
}

§Type Parameters

§
T extends Model = Model
[src]

§Constructors

§
new Collection(name: string, baseUrl: string)
[src]

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

@param name

the Collection name

@param baseUrl

the local base url of data folder

§Properties

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

§Methods

§
delete(id?: string)
[src]

Delete a document when an ID is provided. Otherwise delete the whole collection

@param id

Optional: the document ID to be deleted

@return

an object indicates success

§
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

§
get()
[src]

Get all documents of the collections

§
getById(id: string)
[src]

Get one document by using document ID

@param id

the document ID

§
insert(el: T)
[src]

Insert a document

Caution! In this stage we have not supported bulk insert yet.

@param el

the document to be inserted

@return

the inserted document ID

§
save()
[src]

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

§
update(id: string, el: T)
[src]

Update a document

Caution! In this stage we have not supported bulk update yet.

@param id

the document ID to be updated

@param el

the updated document attributes

@return

the updated document object