Shypyard Database

Shypyard App Database

You can also use the DB methods to persist data on Shypyard.

const shypyard = libs.shypyard.get();
const db = shypyard.db();
​
// store data
// db.set(key: string, val: Object, config?: {expireAt?: Date, expireIn?: number, returnOldValue?: boolean})
await db.set('key', {val: 123});
​
// get data
// db.get(key: string)
const val = await db.get('key');
​
// delete data
// db.del(key: string, config?: {returnOldValue: boolean})
const va = await db.del('key');
​
// increment value (atomically). If the key doesn't exist, start from 0
// db.incr(key: string)
await db.incr('counter');
​
// increment by custom number
// db.incrBy(key: string, num: number);
await db.incrBy('counter', 10);
​
// decrement value
// db.decr(key: string);
await db.decr('counter');
​
// decrement by custom number
// db.decrBy(key: string, num: number);
await db.decrBy('counter', 10);

​