Memory Adapter
@feathersjs/memory
is a service adatper for in-memory data storage that works on all platforms. It is normally not used to store data on a production server but can be useful for data that isn't persistent and to e.g. cache data in browser or React Native applications.
bash
$ npm install --save @feathersjs/memory
tip
The memory adapter implements the common database adapter API and querying syntax.
API
Usage
ts
import { MemoryService } from '@feathersjs/memory'
type Message = {
id: number
text: string
}
type MessageData = Pick<Message, 'text'>
class MyMessageService extends MemoryService<Message, MessageData> {}
app.use('messages', new MyMessageService({}))
Options
The following options are available:
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 sizeallow
(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' ]
)