0.2.9 • Published 5 years ago

moleculer-db-adapter-rethinkdb v0.2.9

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Moleculer logo

moleculer-db-adapter-rethinkdb

RethinkDB adapter for Moleculer DB service.

Coverage Status Build Status NPM version Downloads

Install

$ npm install moleculer-db moleculer-db-adapter-rethinkdb --save

Usage

"use strict";

const { ServiceBroker } = require("moleculer");
const DbService = require("moleculer-db");
const RethinkDBAdapter = require("moleculer-db-adapter-rethinkdb");

const broker = new ServiceBroker();

// Create a RethinkDB service for `post` entities
broker.createService({
    name: "posts",
    mixins: [DbService],
    adapter: new RethinkDBAdapter({host: "127.0.0.1" || "", port: 29015}),
    database: "app",
    table: "posts"
});


broker.start()
// Create a new post
.then(() => broker.call("posts.create", {
    title: "My first post",
    content: "Lorem ipsum...",
    votes: 0
}))

// Get all posts
.then(() => broker.call("posts.find").then(console.log));

// Change feeds
const { client: conn } = this.schema.adapter;
// Lets get a rethinkdb.table instance
const rTable = this.schema.adapter.getTable();
// You can also get a rethinkdb instance with below
// const rethinkdb = this.schema.adapter.getR();

rTable.changes().run(conn, function(err, cursor) {
    cursor.each(console.log);
});

// Map Reduce with same way
rTable.map((user) => 1).run(conn);

// You can access all underlying API

Options

Example with connection options

new RethinkDBAdapter({
    host: "localhost",
    port: 29015
})

Above options is used as default when you dont specify any option or pass empty

Test

$ npm test

In development with watching

$ npm run ci

License

The project is available under the MIT license.

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago