feathers-memory
An in memory CRUD service for feathers
Getting Started
Install the module with: npm install feathers-memory --save
var feathers = require('feathers');
var memory = require('feathers-memory')();
app.configure(feathers.rest()).use('/users', memory);
Documentation
API
The feathers-memory service follows the same convention as all the other services. Therefore, it provides the following methods:
find
, get
, create
, update
, patch
, remove
and setup
.
var memoryService = {
find: function(params, callback) {},
get: function(id, params, callback) {},
create: function(data, params, callback) {},
update: function(id, data, params, callback) {},
patch: function(id, data, params, callback) {},
remove: function(id, params, callback) {},
setup: function(app) {}
}
Usage:
var feathers = require('feathers');
var memory = require('feathers-memory')();
var app = feathers();
app.configure(feathers.rest())
.use('/users', memory)
.listen(8080);
Extending:
You can also extend any of the feathers services to do something custom.
var feathers = require('feathers');
var memory = require('feathers-memory')();
var app = feathers();
var myUserService = memory.extend({
find: function(params, cb){
console.log('I am extending the find method');
this._super.apply(this, arguments);
}
});
app.configure(feathers.rest())
.use('/users', myUserService)
.listen(8080);
Advanced Querying
You are probably also going to want to filter your data. You can do that by passing options via the body or in a query string. Like so:
GET /users?name=eric&limit=10&skip=10
Sort:
GET /users?sort[]=name&sort[]=age
Order:
GET /users?order=ascending
Skip:
GET /users?skip=10
Limit:
GET /users?limit=10
Examples
See examples directory.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
0.3.0
- Fixing how the module is exported.
- Adding
PATCH
support back in
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
License
Copyright (c) 2014 Eric Kryski
Licensed under the MIT license.