feathers-memory
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 = ; app;app;
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 storeevents
(optional) - A list of custom service events sent by this servicepaginate
(optional) - A pagination object containing adefault
andmax
page sizewhitelist
(optional) - A list of additional query parameters to allowmulti
(optional) - Allowcreate
with arrays andupdate
andremove
withid
null
to change multiple items. Can betrue
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 = ;const express = ;const socketio = ; const memory = ; // Create an Express compatible Feathers application instance.const app = ;// Turn on JSON parser for REST servicesapp;// Turn on URL-encoded parser for REST servicesapp;// Enable REST servicesapp;// Enable REST servicesapp;// Create an in-memory Feathers service with a default page size of 2 items// and a maximum size of 4app;// Set up default error handlerapp; // Create a dummy Messageapp; // Start the server.const port = 3030; app;
Run the example with node app
and go to localhost:3030/messages.
License
Copyright (c) 2017
Licensed under the MIT license.