igthorn-rethinkdb-gateway

1.0.0 • Public • Published

Igthorn RethinkDB Gateway

Igthorn

RethinkDB gateway allows CRUD on RethinkDB.

Build Status

Igthorn RethinkDB Gateway is a package that provides gateway class to run CRUD operations on RethinkDB using igthorn-request(to query) and igthorn-entity(to save, update and replace). It's part of Igthorn project

Usage

Typical usage would be to query for data using igthorn-request middleware which would be attached to every GET route of application(route would receive Request object(ightorn-request) as a part of request object and pass forward to gateway - class extending rethinkDbGateway from this package and defining 'relations'). Below, how it works in background:

  const sampleRequestData = {
    "joins": [
      "role"
    ],
    "fields": {
      "u.firstName": "userFirstName",
      "r.name": "role"
    }
  };

  var request = new Request();
  request.inflate(sampleRequestData);

  rethinkDbUserGateway.fetchAll(request)
    .then(function(results) {

      // console.log(results) - query result

    }).catch(function(error) {
      done(error);
    });

Methods

Request class implements following methods:

  • fetchAll(request:IghtornRequest) : promise

To do

  • Support different types of joins

  • Refactor querying to subclass and move code to ES6 (const, let)

License

MIT

Package Sidebar

Install

npm i igthorn-rethinkdb-gateway

Homepage

igthorn.com

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • hedonsoftware