Class: Collection<T>
Defined in: ridb_core.d.ts:504
Collection is a class that represents a collection of documents in a database.
Type Parameters
T
T extends SchemaType
A schema type defining the structure of the documents in the collection.
Constructors
Constructor
new Collection<T>(): Collection<T>
Returns
Collection<T>
Methods
count()
count(query, options?): Promise<number>
Defined in: ridb_core.d.ts:516
count all documents in the collection.
Parameters
query
QueryType<T>
options?
Returns
Promise<number>
A promise that resolves to an array of documents.
create()
create(document): Promise<Doc<T>>
Defined in: ridb_core.d.ts:537
Creates a new document in the collection.
Parameters
document
CreateDoc<T>
The document to create.
Returns
Promise<Doc<T>>
A promise that resolves to the created document.
delete()
delete(id): Promise<void>
Defined in: ridb_core.d.ts:544
Deletes a document in the collection by its ID.
Parameters
id
string
The ID of the document to delete.
Returns
Promise<void>
A promise that resolves when the deletion is complete.
find()
find(query, options?): Promise<Doc<T>[]>
Defined in: ridb_core.d.ts:510
Finds all documents in the collection.
Parameters
query
QueryType<T>
options?
Returns
Promise<Doc<T>[]>
A promise that resolves to an array of documents.
findById()
findById(id): Promise<Doc<T>>
Defined in: ridb_core.d.ts:523
Finds a single document in the collection by its ID.
Parameters
id
string
The ID of the document to find.
Returns
Promise<Doc<T>>
A promise that resolves to the found document.
update()
update(document): Promise<void>
Defined in: ridb_core.d.ts:530
Updates a document in the collection by its ID.
Parameters
document
Partial<Doc<T>>
A partial document containing the fields to update.
Returns
Promise<void>
A promise that resolves when the update is complete.