Skip to content

Commit

Permalink
chore: add jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnagydavid committed Sep 30, 2024
1 parent d36c67b commit b02fb61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/kv/commonKeyValueDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@ export interface CommonKeyValueDB {

count: (table: string) => Promise<number>

/**
*
* Increments the value of a key in a table by a given amount.
* Default increment is 1 when `by` is not provided.
*
* Returns the new value.
*/
increment: (table: string, id: string, by?: number) => Promise<number>
}
6 changes: 6 additions & 0 deletions src/kv/commonKeyValueDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ export class CommonKeyValueDao<T> {
)
}

/**
* Increments the `id` field by the amount specified in `by`,
* or by 1 if `by` is not specified.
*
* Returns the new value of the field.
*/
async increment(id: string, by = 1): Promise<number> {
return await this.cfg.db.increment(this.cfg.table, id, by)
}
Expand Down

0 comments on commit b02fb61

Please sign in to comment.