Api Reference
Query
constructor(options: QueryOptions)
Create a new query instance.
.createCollection(name: string)
Create a new collection by giving it a name and document type.
Collection
.set(id: string, data: T): Promise<void>
Insert a new document to the collection. This will throw an error if the document already exists.
.get(id: string): Promise<Document<T> | null>
Get a document by id.
.delete(id: string): Promise<void>
Delete a document by id.
.update(id: string, data: T): Promise<void>
Update a document by id. This will throw an error if the document does not exist.
.createIndex(options: CreateIndexOptions<T>): Index<T>
Create a new index on the collection. The terms field will be strongly typed depending on the type you have passed in when creating the collection.
Index
.match(query): Promise<Document<T>[]>
Search for matches in the index.
The query
argument is strongly typed depending on the terms you have passed in when creating the index.
.reIndex(): Promise<void>
Rebuild the index. This might be necessary if you are adding an index after documents are already in the collection.
reIndex
will go through the entire collection and rebuild the index, depending on the size of the collection this might take a while.
.delete(): Promise<void>
Delete the index and all its data. The items in the collection will not be affected.