Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

feathers-memory

feathersjs-ecosystem20.2kMITdeprecated4.1.0TypeScript support: included

This module has moved to @feathersjs/memory. See the documentation at https://feathersjs.com/api/databases/memory.html

An in memory service store

feathers, feathers-plugin

readme

feathers-memory

Greenkeeper badge

Build Status Dependency Status Download Status

A Feathers service adapter for in-memory data storage that works on all platforms.

$ npm install --save feathers-memory

Important: feathers-memory implements the Feathers Common database adapter API and querying syntax.

API

service([options])

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 }));

Options:

  • 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
  • whitelist (optional) - A list of additional query parameters to allow
  • multi (optional) - Allow create with arrays and update and remove with id null to change multiple items. Can be true for all methods or an array of allowed methods (e.g. [ 'remove', 'create' ])

Example

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

$ npm install @feathersjs/feathers @feathersjs/express @feathersjs/socketio @feathersjs/errors feathers-memory

In app.js:

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');

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

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

// Create a dummy Message
app.service('messages').create({
  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.

License

Copyright (c) 2017

Licensed under the MIT license.

changelog

Change Log

v4.0.1 (2019-09-29)

Full Changelog

Closed issues:

  • An in-range update of @types/node is breaking the build 🚨 #101
  • An in-range update of webpack is breaking the build 🚨 #98

Merged pull requests:

v4.0.0 (2019-07-05)

Full Changelog

Merged pull requests:

v3.0.2 (2019-01-24)

Full Changelog

Closed issues:

  • Multiple patch records #92

Merged pull requests:

v3.0.1 (2018-12-29)

Full Changelog

Merged pull requests:

  • Add default params to hook-less methods #89 (daffl)

v3.0.0 (2018-12-17)

Full Changelog

Closed issues:

  • An in-range update of webpack is breaking the build 🚨 #84
  • An in-range update of @feathersjs/errors is breaking the build 🚨 #83

Merged pull requests:

v2.2.0 (2018-08-26)

Full Changelog

Closed issues:

  • Previously functional batch service no longer works when creating in-memory service #77

Merged pull requests:

v2.1.3 (2018-06-11)

Full Changelog

Closed issues:

  • Use with create-react-app #74

Merged pull requests:

v2.1.2 (2018-06-03)

Full Changelog

Merged pull requests:

v2.1.1 (2018-03-07)

Full Changelog

Closed issues:

  • Why are all the data deleted after the server is rebooted? #68

Merged pull requests:

v2.1.0 (2017-12-03)

Full Changelog

Merged pull requests:

  • Use namespaced module name for exporting #64 (daffl)

v2.0.0 (2017-12-03)

Full Changelog

Merged pull requests:

v1.3.1 (2017-10-20)

Full Changelog

Closed issues:

  • Custom $select returning id #58
  • Best practice for $search #51

Merged pull requests:

  • Do not select the id by default #59 (daffl)

v1.3.0 (2017-10-19)

Full Changelog

Merged pull requests:

v1.2.1 (2017-09-13)

Full Changelog

v1.2.0 (2017-09-13)

Full Changelog

Closed issues:

  • [RFE] An option to set the type of the id field to String #54

Merged pull requests:

v1.1.0 (2017-01-31)

Full Changelog

Merged pull requests:

  • Allow to pass a custom matcher and sorter in the options #47 (daffl)
  • Change var to const, fix a mistake with feathers-memory requiring #46 (osenvosem)

v1.0.1 (2016-11-15)

Full Changelog

Merged pull requests:

v1.0.0 (2016-11-11)

Full Changelog

Closed issues:

  • Support $select for gets #35

Merged pull requests:

v0.8.1 (2016-11-02)

Full Changelog

Merged pull requests:

v0.8.0 (2016-09-08)

Full Changelog

Closed issues:

  • Remove object from memory once sent? #30

Merged pull requests:

v0.7.5 (2016-07-25)

Full Changelog

v0.7.4 (2016-07-21)

Full Changelog

Merged pull requests:

v0.7.3 (2016-06-16)

Full Changelog

Merged pull requests:

v0.7.2 (2016-06-14)

Full Changelog

Closed issues:

  • Support $search #14

Merged pull requests:

v0.7.1 (2016-04-05)

Full Changelog

v0.7.0 (2016-04-04)

Full Changelog

Merged pull requests:

  • Move to feathers-commons utilities #20 (daffl)

v0.6.3 (2016-02-25)

Full Changelog

Closed issues:

  • Upgrade to lodash 4 #17

Merged pull requests:

  • Use individual Lodash methods #19 (daffl)

v0.6.2 (2016-02-24)

Full Changelog

Merged pull requests:

v0.6.1 (2016-02-22)

Full Changelog

Merged pull requests:

v0.6.0 (2016-01-30)

Full Changelog

Merged pull requests:

  • Use internal methods instead of service methods directly #13 (daffl)

v0.5.3 (2016-01-23)

Full Changelog

v0.5.2 (2016-01-23)

Full Changelog

Merged pull requests:

v0.5.1 (2015-12-19)

Full Changelog

v0.5.0 (2015-12-03)

Full Changelog

v0.4.1 (2015-12-03)

Full Changelog

Merged pull requests:

  • Use ES6 classes, Promises and support pagination #11 (daffl)

v0.4.0 (2015-11-07)

Full Changelog

Closed issues:

  • How properly append values to an existing memory element #9
  • how to initialize memory on app startup #8
  • Add query-filter support #7
  • Remove sorting and other processing from core service #4

Merged pull requests:

  • Migrate to ES6 plugin infrastructure and shared feathers-service-tests #10 (daffl)
  • Added support for simple query in find #6 (ruimgoncalves)

0.3.4 (2014-09-25)

Full Changelog

Closed issues:

  • Query and persisting Data #5

0.3.3 (2014-06-13)

Full Changelog

0.3.2 (2014-06-13)

Full Changelog

0.3.1 (2014-06-13)

Full Changelog

Closed issues:

  • Fix peer dependency #3
  • Should support patch service method #2
  • Need to return proper errors #1

0.3.0 (2014-06-05)

Full Changelog

0.2.1 (2014-06-04)

Full Changelog

0.2.0 (2014-04-22)

Full Changelog

0.1.2 (2014-04-11)

Full Changelog

0.1.1 (2014-04-11)

* This Change Log was automatically generated by github_changelog_generator