In Memory

GitHub stars npm version Changelog

feathers-memory is a database service adapter for in-memory data storage that works on all platforms.

$ npm install --save feathers-memory

Important: To use this adapter you also want to be familiar with the database adapter common API and querying mechanism.



Returns a new service instance initialized with the given options.

const service = require('feathers-memory');

app.use('/messages', service());
app.use('/messages', service({ id, startId, store, events, paginate }));


  • id (optional, default: 'id') - The name of the id field property.
  • startId (optional, default: 0) - An id number to start with that will be incremented for every new record (unless it is already set).
  • store (optional) - An object with id to item assignments to pre-initialize the data store
  • events (optional) - A list of custom service events sent by this service
  • paginate (optional) - A pagination object containing a default and max page size


Here is an example of a Feathers server with a messages in-memory service that supports pagination:

$ npm install feathers body-parser feathers-rest feathers-socketio feathers-memory feathers-errors

In app.js:

const feathers = require('feathers');
const bodyParser = require('body-parser');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const memory = require('feathers-memory');
const errorHandler = require('feathers-errors/handler');

// Create a feathers instance.
const app = feathers()
  // Enable REST services
  // Enable REST services
  // Turn on JSON parser for REST services
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({ extended: true }))
  // Create an in-memory Feathers service with a default page size of 2 items
  // and a maximum size of 4
  .use('/messages', memory({
    paginate: {
      default: 2,
      max: 4
  // Set up default error handler

// Create a dummy Message
  text: 'Message created on server'
}).then(message => console.log('Created message', message));

// Start the server.
const port = 3030;

app.listen(port, () => {
  console.log(`Feathers server listening on port ${port}`)

Run the example with node app and go to localhost:3030/messages.

results matching ""

    No results matching ""