fh-rest-memory-adapter
Creates an adapter that uses process memory to store data. Created adapters do not share memory!
IMPORTANT NOTE: This is useful for debugging and local development, but should not be used in a real application since it's a volatile store and would lead to data loss and inconsistency upon MBaaS Service process restarts.
Install
npm install feedhenry-staff/fh-rest-memory-adapter
Usage
Red Hat Mobile MBaaS Service
'use strict'; /** * filename: application.js * The entry point of our RHAMP MBaaS Service */ var express = mbaasApi = mbaasExpress = mbaasApi app = moduleexports = log = ; log; // Note: the order which we add middleware to Express here is important!app;app; // Note: important that this is added just before your own Routesapp; // Module used to create RESTful router instancesvar fhRestExpressRouter = ; // Module that RESTful router will use to retrieve data// Note: this is not yet developedvar fhRestMemoryAdapter = ; // Creates a handler for incoming HTTP requests that want to perform CRUDL// operations on the "orders" dataset stored in memoryvar ordersRouter = // Expose a RESTful API to orders data, e.g:// GET /orders/12345app; // Important that this is last!app; var port = processenvFH_PORT || processenvVCAP_APP_PORT || 8001;app;
Direct API
module(opts)
This module behaves as a factory function. Created adapters do not share memory!
var memoryAdapter = ; var catStore = ;var dogStore = ; catStore; dogStore; dogStore; dogStore; catStore;
adapter.create(params, callback)
Create an item in the store.
store;
adapter.read(params, callback)
Read an item. id must be passed in the params.
store;
adapter.update(params, callback)
Update an item in the store. id and data must be passed in the params.
store;
adapter.delete(params, callback)
Delete an item in the store. id must be passed in the params.
store;
adapter.list(params, callback)
List items in the store.
store;