Code Monkey home page Code Monkey logo

feathers-rethinkdb's Introduction

feathers-rethinkdb

Build Status

Create a RethinkDB Service for FeatherJS.

Installation

npm install rethinkdbdash feathers-rethinkdb --save

Documentation

Please refer to the Feathers database adapter documentation for more details or directly at:

The feathers-rethinkdb adapter is built to use rethinkdbdash, which is a progressive version of the RethinkDB node driver which simplifies the connection process. It also provides some other benefits like connection pooling .

Complete Example

Here's an example of a Feathers server with a messages RethinkDB service.

const rethink = require('rethinkdbdash');
const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const bodyParser = require('body-parser');
const service = require('../lib');

// Connect to a local RethinkDB server.
const r = rethink({
  db: 'feathers'
});

// Create a feathers instance.
var app = feathers()
  // Enable the REST provider for services.
  .configure(rest())
  // Enable the socketio provider for services.
  .configure(socketio())
  // Turn on JSON parser for REST services
  .use(bodyParser.json())
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({extended: true}));

// Create your database if it doesn't exist.
r.dbList().contains('feathers')
  .do(dbExists => r.branch(dbExists, {created: 0}, r.dbCreate('feathers'))).run()

  // Create the table if it doesn't exist.
  .then(() => {
    return r.db('feathers').tableList().contains('messages')
      .do(tableExists => r.branch( tableExists, {created: 0}, r.dbCreate('messages'))).run();
  })
		
  // Create and register a Feathers service.
  .then(() => {
    app.use('messages', service({
      Model: r,
      name: 'messages',
      paginate: {
        default: 10,
        max: 50
      }
    }));
  })
  .catch(err => console.log(err));

// Start the server.
var port = 3030;
app.listen(port, function() {
  console.log(`Feathers server listening on port ${port}`);
});

You can run this example by using node example/app and going to localhost:3030/messages. You should see an empty array. That's because you don't have any Todos yet but you now have full CRUD for your new messages service.

Changelog

0.2.0

  • Some minor cleanup
  • Getting all tests passing
  • Adding support for change feeds

0.1.0

  • Initial release.

License

Copyright (c) 2016

Licensed under the MIT license.

Author

Marshall Thompson

feathers-rethinkdb's People

Contributors

codermapuche avatar daffl avatar ekryski avatar marshallswain avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.