https://github.com/adrienjoly/persistent-harmony
A wrapper class to create persistent javascript objects, relying on harmony proxies.
https://github.com/adrienjoly/persistent-harmony
harmony-proxies javascript-objects nodejs npm-package persistence
Last synced: 7 months ago
JSON representation
A wrapper class to create persistent javascript objects, relying on harmony proxies.
- Host: GitHub
- URL: https://github.com/adrienjoly/persistent-harmony
- Owner: adrienjoly
- Created: 2013-06-26T21:02:50.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-02T10:53:12.000Z (almost 12 years ago)
- Last Synced: 2025-02-28T20:48:02.915Z (7 months ago)
- Topics: harmony-proxies, javascript-objects, nodejs, npm-package, persistence
- Language: JavaScript
- Size: 143 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
## Usagevar 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
[](https://github.com/igrigorik/ga-beacon)