2.1.0 • Published 2 years ago
hapi-tyrdb v2.1.0
Hapi-TyrDB
TyrDB connection plugin for Hapi
Table of Contents
Installation
npm install hapi-tyrdb
Usage
const dbOpts = {
path: '.db',
db:'test',
adapter:'FsAdapter'
};
await server.register({plugin:require('hapi-tyrdb'), options:dbOpts});
const colOpts = { uniques :['email']};
const {db}= server;
const col = await db.collection('users', colOpts);
const doc = await col.insert({name:'Alex'});
const [alex] = await col.find({name:'Alex'});
alex.name='Jean';
await col.replace(alex);
await col.get(alex._id);
await col.remove({name:'Jean'});See more into the TyrDB documentation. You might also want to look into the Tree Engine of TyrDB: SBTree documentation.
DB Options
adapterAdapter - (def: MemoryAdapter()) : Allow to specific another adapter to useautoInitializeAdapter - (def: true) : If true, will auto init the dbautoConnectAdapter - (def: true) : If true, will auto connect the dbpathAdapter - (def: '.db') : Desired relative path to persist the data
Col Options
orderNumber - (def: 511) : Primordial for the performance, the closest to L1 the better. Chose below 2^n.uniquesArray - (def: []) - Allow to set some field unique by adding them to this arrayexcludeArray - (def: []) - Allow to exclude from indexing some field (important if you expect field value to be huge or nested).