2.1.0 • Published 7 months ago

hapi-tyrdb v2.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 months ago

Hapi-TyrDB

NPM Version Build Status Release Date standard-readme compliant

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

  • adapter Adapter - (def: MemoryAdapter()) : Allow to specific another adapter to use
  • autoInitialize Adapter - (def: true) : If true, will auto init the db
  • autoConnect Adapter - (def: true) : If true, will auto connect the db
  • path Adapter - (def: '.db') : Desired relative path to persist the data

Col Options

  • order Number - (def: 511) : Primordial for the performance, the closest to L1 the better. Chose below 2^n.
  • uniques Array - (def: []) - Allow to set some field unique by adding them to this array
  • exclude Array - (def: []) - Allow to exclude from indexing some field (important if you expect field value to be huge or nested).
2.1.0

7 months ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago