JSPM

  • Created
  • Published
  • Downloads 489
  • Score
    100M100P100Q139059F
  • License MIT

Feathers NeDB Service

Package Exports

  • feathers-nedb

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (feathers-nedb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

feathers-nedb

Build Status Code Climate

Create an NeDB Service for FeatherJS.

Installation

npm install nedb feathers-nedb --save

Documentation

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

  • NeDB - The detailed documentation for this adapter
  • Extending - How to extend a database adapter
  • Pagination and Sorting - How to use pagination and sorting for the database adapter
  • Querying - The common adapter querying mechanism

Complete Example

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

import NeDB from 'nedb';
import feathers from 'feathers';
import bodyParser from 'body-parser';
import service from '../lib';

const db = new NeDB({
  filename: './db-data/messages',
  autoload: true
});

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

// Connect to the db, create and register a Feathers service.
app.use('messages', service({
  Model: db,
  paginate: {
    default: 2,
    max: 4
  }
}));

// 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.

License

Copyright (c) 2016

Licensed under the MIT license.

Author

Marshall Thompson