Builtin functions
insert()
This function is used to create new documents and update existing ones in the database. Creation will be performed when the _id
property is absent from the payload.what
, otherwise insert will update the specified properties in the document with the given _id
. Insert will either return a Result
with the latest version of the created or updated document with it's _id
, or a Error
with access control or validation errors.
This function is automatically bound to the POST
method on the /collectionName
route.
Type:
type InsertPayload<TDocument extends CollectionDocument<any>> = {
what: What<TDocument & { _id?: any }>
project?: Projection<TDocument>
}
count()
This function is used to retrieve the number of existent documents matching passed filters.
Type:
type CountPayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
filters?: Filters<TDocument>
}
get()
This function is used to retrieve the first document from the database matching specified filters. It is associated with the GET
method on the /collectionName/:id
route.
Type:
type GetPayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
filters?: Filters<TDocument>
project?: Projection<TDocument>
}
getAll()
This function is used to retrieve a array of documents from the database matching specified filters. It is associated with the GET
method on /collectionName
route.
Type:
type GetAllPayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
filters?: Filters<TDocument>
project?: Projection<TDocument>
offset?: number
limit?: number
sort?: QuerySort<TDocument>
}
remove()
This function is used to delete a single document from the database given a set of filters. Remove is automatically bound to the DELETE
method on the /collectionName/:id
route.
Type:
type RemovePayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
filters: Filters<TDocument>
}