Skip to content

adrienjoly/persistent-harmony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persistent-harmony

A node.js wrapper class to create persistent javascript objects, relying on harmony proxies.

Rationale / use case

I developed this module because:

  • I was generating big hashmaps / associative arrays in node.js, indexing data computed from my MongoDB database
  • I wanted to store the resulting javascript objects to my database so that I could load them back to memory, instead of re-computing the indices at every restart of my node.js app.
  • I didn't want to update and query these indices using asynchronous mongodb calls, but use native javascript structures instead (sychronous and fast).

Installation

npm install persistent-harmony

Usage

var ph = require("persistent-harmony");
new ph.MongoPH({/* default mongodb args */}, function(mongoPH){
	var mymap = mongoPH.wrap("mymap", {/* empty object instance */}, function(){
		console.log("mymap is now synchronized to its mongodb collection");
		mymap.first = "coucou"; // => stored as {_id:"first", v:"coucou"} in mongodb
		console.log("myapp", mymap);
	});
});

Don't forget to add the --harmony-proxies when starting node!

node --harmony-proxies tests.js

Analytics

About

A wrapper class to create persistent javascript objects, relying on harmony proxies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy