MCPcopy Create free account
hub / github.com/adonisjs/session / increment

Method increment

src/values_store.ts:213–220  ·  view source on GitHub ↗

* Increments a numeric value. Raises an error when underlying value is not a number. * * @param key - The key or key path to increment * @param steps - Number of steps to increment (default: 1) * * @example * store.increment('page_views') // Increments by 1 * store.increment

(key: string | string[], steps: number = 1)

Source from the content-addressed store, hash-verified

211 * store.increment('score', 10) // Increments by 10
212 */
213 increment(key: string | string[], steps: number = 1): void {
214 const value = this.get(key, 0)
215 if (typeof value !== 'number') {
216 throw new RuntimeException(`Cannot increment "${key}". Existing value is not a number`)
217 }
218
219 this.set(key, value + steps)
220 }
221
222 /**
223 * Decrements a numeric value. Raises an error when underlying value is not a number.

Callers

nothing calls this directly

Calls 2

setMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected