Skip to content

ES6 module for providing a simple interface to a kind of database (only in memory) to be used for training/lectures (not productivity)

License

Notifications You must be signed in to change notification settings

jkonert/simple-memory-store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-memory-store

ES6 module for providing a simple interface to a kind of database (only in memory) to be used for training/lectures (not productivity). Objects stored are identified by .id attribute, which is automatically set and incremented (starting with 100) over all collections (called types). On insert(..) operation .id must not be set (and will be added by the insert method).

This simple-memory-store is not intended to be used for production use, but only for training or lecture purposes!

Usage

const store = new (require('simple-memory-store'))();

require(..) will return the ES6 class Store, which you need to create an instance from. Constructor has no parameters.

methods exposed as public

  • select (String type, Number id = undefined) @returns undefined, copy of one element or array of copied elements, if id is omitted
  • insert (String type, Object element) @returns the new element as a copy with set .id attribute
  • replace (String type, Number id, Object element) @returns the former object stored before
  • remove (String type, Number id) @returns the former object stored before

All methods throw Errors if something went wrong.

Elements stored in store are expected to have an .id property with a numeric value > 0 (except on insert(..))

About

ES6 module for providing a simple interface to a kind of database (only in memory) to be used for training/lectures (not productivity)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published