feathers-rethinkdb-jkr3
v0.4.3-jkr3
Published
A RethinkDB Service for FeathersJS
Downloads
3
Maintainers
Readme
为正在开发的项目加上一些功能 @JKR3_TEAM
feathers-rethinkdb
Installation
npm install rethinkdbdash feathers-rethinkdb --save
Documentation
Please refer to the Feathers database adapter documentation for more details or directly at:
- RethinkDB - The detailed documentation for this adapter
- Extending - How to extend a database adapter
- Pagination - How to use pagination
- Querying and Sorting - The common adapter querying mechanism and sorting for the database adapter
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.
Pro tip: For faster queries, create indexes on your table beforehand as described here.
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}));
var messages = service({
Model: r,
name: 'messages',
paginate: {
default: 10,
max: 50
}
}))
messages
.init()
.then(() => {
// mount the service
app.use('messages', messages);
// start the server.
const 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.
License
Copyright (c) 2016
Licensed under the MIT license.