Skip to content

Commit

Permalink
chore: updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-oloughlin committed Nov 27, 2023
1 parent 4fceabb commit 4a2906e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
20 changes: 12 additions & 8 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ export class Collection<
}

/**
* Adds a new document to the KV store with a randomely generated id.
* Adds a new document to the KV store with a generated id.
*
* Does not overwrite existing documents with coliiding id.
*
* @example
* ```ts
Expand All @@ -407,7 +409,7 @@ export class Collection<
*
* @param data - Document value.
* @param options - Set options, optional.
* @returns Promise resolving to a CommitResult object.
* @returns Promise resolving to a CommitResult or CommitError.
*/
async add(value: ParseInputType<TInput, TOutput>, options?: SetOptions) {
// Set document value with generated id
Expand All @@ -417,6 +419,8 @@ export class Collection<
/**
* Adds a new document with the given id to the KV store.
*
* Does not overwrite existing documents with coliiding id.
*
* @example
* ```ts
* const result = await db.users.set("oliver", {
Expand All @@ -428,7 +432,7 @@ export class Collection<
* @param id - Document id.
* @param data - Document value.
* @param options - Set options, optional.
* @returns Promise resolving to a CommitResult object.
* @returns Promise resolving to a CommitResult or CommitError.
*/
async set(
id: KvId,
Expand All @@ -455,7 +459,7 @@ export class Collection<
* @param id - Document id.
* @param value - Document value.
* @param options - Set options, optional.
* @returns Promise resolving to a CommitResult object.
* @returns Promise resolving to a CommitResult or CommitError.
*/
async write(
id: KvId,
Expand Down Expand Up @@ -668,8 +672,8 @@ export class Collection<
* this method overrides the old value with the new one.
*
* For custom object types, this method merges the
* new data with the exisiting data using shallow merge
* by default, or optionally using deep merge.
* new data with the exisiting data using deep merge
* by default, or optionally using shallow merge.
*
* @example
* ```ts
Expand Down Expand Up @@ -840,7 +844,7 @@ export class Collection<
}

/**
* Adds multiple documents to the KV store.
* Adds multiple documents to the KV store with generated ids.
*
* @example
* ```ts
Expand All @@ -862,7 +866,7 @@ export class Collection<
*
* @param values - Document values to be added.
* @param options - Set options, optional.
* @returns A promise that resolves to a list of Deno.KvCommitResult or Deno.KvCommitError objects
* @returns A promise that resolves to a list of CommitResults or CommitErrors.
*/
async addMany(
values: ParseInputType<TInput, TOutput>[],
Expand Down
7 changes: 4 additions & 3 deletions src/kvdex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { AtomicWrapper } from "./atomic_wrapper.ts"
* const db = kvdex(kv, {
* numbers: collection(model<number>()),
* u64s: collection(model<Deno.KvU64>()),
* serializedStrings: collection(model<string>(), { serialized: true }),
* serializedStrings: collection(model<string>(), { serialize: true }),
* users: collection(model<User>(), {
* indices: {
* username: "primary",
Expand Down Expand Up @@ -140,8 +140,9 @@ export class KvDex<const TSchema extends Schema<SchemaDefinition>> {
}

/**
* Initiates an atomic operation.
* Takes a selector function as argument which is used to select an initial collection.
* Initializes an atomic operation.
*
* Takes a selector function as argument which is used to select an initial collection context.
*
* @example
* ```ts
Expand Down

0 comments on commit 4a2906e

Please sign in to comment.