import { IndexableCollection } from "https://deno.land/x/kvdex@v0.3.0/mod.ts";
Represents a collection of object documents stored in the KV store.
Contains methods for working on documents in the collection, including exclusive indexing methods.
Type Parameters
T1 extends Model
T2 extends IndexRecord<T1>
Properties
readonly
keys: IndexableCollectionKeysMethods
addMany<TEntries extends [T1, ...T1[]]>(...entries: TEntries): Promise<Deno.KvCommitResult | Deno.KvCommitError>
deleteMany(options?: ListOptions<T1>)
findByPrimaryIndex(selection: PrimaryIndexSelection<T1, T2>, options?: FindOptions)
Find a document by index value. Note that selecting an index that was not defined when creating the collection will always return null.
Example:
// Returns a single result
const userByUsername = await db.users.findByPrimaryIndex({
username: "oli"
})
findBySecondaryIndex(selection: SecondaryIndexSelection<T1, T2>, options?: ListOptions<T1>)
Finds documents by a given set of secondary indices. If multiple are specified, results are combined.
Example:
// Returns a list of user documents
const usersByAge = await db.users.findBySecondaryIndex({
age: 24
})
update<TId extends KvId>(id: TId, data: Partial<T1>): Promise<CommitResult<T1, TId>>