# feathers-memory

> An in memory service store

Latest version **4.1.0** (published 2019-10-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install feathers-memory
pnpm add feathers-memory
yarn add feathers-memory
bun add feathers-memory
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2019-10-07 |
| First published | 2014-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 8 |
| Dependencies | 4 |
| Unpacked size | 303 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Feathers contributors |
| Maintainers | daffl, ekryski, marshallswain |
| Keywords | feathers, feathers-plugin |

## Links

- npm: https://www.npmjs.com/package/feathers-memory
- Repository: https://github.com/feathersjs-ecosystem/feathers-memory
- Issues: https://github.com/feathersjs-ecosystem/feathers-memory/issues
- npm.io page: https://npm.io/package/feathers-memory

## Dependencies (4)

- [sift](https://npm.io/package/sift.md) ^8.5.0
- [@feathersjs/errors](https://npm.io/package/@feathersjs/errors.md) ^4.3.4
- [@feathersjs/commons](https://npm.io/package/@feathersjs/commons.md) ^4.3.0
- [@feathersjs/adapter-commons](https://npm.io/package/@feathersjs/adapter-commons.md) ^4.3.6

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2019-10-07
- 4.0.1 — 2019-09-29
- 4.0.0 — 2019-07-05
- 3.0.2 — 2019-01-24
- 3.0.1 — 2018-12-29
- 3.0.0 — 2018-12-17
- 2.2.0 — 2018-08-26
- 2.1.3 — 2018-06-11
- 2.1.2 — 2018-06-03
- 2.1.1 — 2018-03-07
- 2.1.0 — 2017-12-03
- 2.0.0 — 2017-12-03
- 1.3.1 — 2017-10-20
- 1.3.0 — 2017-10-19
- 1.2.1 — 2017-09-13
- … 32 more at https://npm.io/package/feathers-memory/versions

## README

# feathers-memory

[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs-ecosystem/feathers-memory.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/feathersjs-ecosystem/feathers-memory.png?branch=master)](https://travis-ci.org/feathersjs-ecosystem/feathers-memory)
[![Dependency Status](https://img.shields.io/david/feathersjs-ecosystem/feathers-memory.svg?style=flat-square)](https://david-dm.org/feathersjs-ecosystem/feathers-memory)
[![Download Status](https://img.shields.io/npm/dm/feathers-memory.svg?style=flat-square)](https://www.npmjs.com/package/feathers-memory)

A [Feathers](https://feathersjs.com) service adapter for in-memory data storage that works on all platforms.

```bash
$ npm install --save feathers-memory
```

> __Important:__ `feathers-memory` implements the [Feathers Common database adapter API](https://docs.feathersjs.com/api/databases/common.html) and [querying syntax](https://docs.feathersjs.com/api/databases/querying.html).


## API

### `service([options])`

Returns a new service instance initialized with the given options.

```js
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](https://docs.feathersjs.com/api/events.html#custom-events) sent by this service
- `paginate` (*optional*) - A [pagination object](https://docs.feathersjs.com/api/databases/common.html#pagination) 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`:

```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](http://localhost:3030/messages).

## License

Copyright (c) 2017

Licensed under the [MIT license](LICENSE).

---
_Source: https://npm.io/package/feathers-memory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
