GithubHelp home page GithubHelp logo

nodejspersistor's Introduction

NodeJsPersistor

Based on https://github.com/Glazr/glazr-persistor. Has been minimized to only include portions that I need.

#####Currently supports persistence via:

##Usage

var
  Persistor = require('NodeJsPersistor'),
  persistor,
  options;

  options = {
    type: 'LocalFile',
    config: {
      filePath: 'some/path/file.txt'
      }
    };

  persistor = new Persistor(options);

##Api

create(record, callback)

######@param {object} record - The object to create. ######@param {function(err, id)} callback

The callback returns the object's new id upon successful creation.

get(id, callback)

######@param{string} id - The id of the record to retrieve. ######@param{function(err, record)} callback

The callback returns the record upon successful retrieval.

getAll(callback)

######@param{function(err, records)} callback - records is expected to be an array of objects.

The callback returns an array of records upon successful retrieval.

update(updatedRecord, callback)

######@param{object} updatedRecord - Has the mandatory parameter of 'id'. ######@param{function(err)} callback

The callback returns nothing on successful update.

remove(id, callback)

######@param{string} id ######@param{function(err)} callback

The callback returns nothing on successful removal of the record.

LocalFile

LocalFile stores all data in one file in json format. Not recommended for large amounts of data.

options = {
  type: 'LocalFile',
  config: {
    filePath: 'some/path/toaFile.txt'
    }
  };

NOTE: Local files do have a maximum size limit before trouble can occur. Storing something like ~50 screenshots in one file can cause your node/docker server to restart losing all data.

MultiFile

MultiFile stores each record in it's own file in json format.

options = {
  type: 'MultiFile',
  config: {
    dir: 'some/path/toTheContainingDirectory'
    }
  };

NOTE: Local files do have a maximum size limit before trouble can occur. Storing something like ~50 screenshots in one file can cause your node/docker server to restart losing all data.

nodejspersistor's People

Contributors

sel-en-ium avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.