You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

entity-promises

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

entity-promises - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+4
-1
index.js

@@ -74,4 +74,7 @@ /*jslint node: true */

/*
* cleaner for mongo documents
*/
exports.moclean = createCleaner("_id");
+1
-1
{
"name": "entity-promises",
"version": "0.0.2",
"version": "0.0.3",
"description": "Promise functions for working with model entities",

@@ -5,0 +5,0 @@ "main": "index.js",

+22
-18

@@ -7,6 +7,8 @@ ## Entity Promises

- createIntroducer: produce a function that augments objects with an id
- introduce: pre-built introducer with an internal id generator
- createCleaner: produce a function that removes persistence cruft
- createIntroducer: Produce a function that augments objects with an id. Invoke with an id generator function. e.g. createIntroducer(intSeq) .
- introduce: Pre-built introducer with an internal random id generator
- createCleaner: produce a function that removes persistence artifacts. Invoke with a list of hash keys to remove.
- moclean: Pre-built cleaner that removes mongodb persistence ids. e.g. createCleaner("_id") .
Both introducers and cleaners each operate on a single instance or an array of instances.

@@ -17,13 +19,6 @@ Example:

u = require("underscore"),
mongocoll = ...,
introduce,
clean;
q = require("q"),
model = require("./model")
mongocoll = require("mongodb-q").connect().collection("trains");
introduce = entityp.createIntroducer(anIdGenerator); // caller-suppplied id generator
clean = entityp.createCleaner("_id"); // remove mongo identifiers
function entity(spec) {
....
}
/* create and persist entity instance from specification. Return a promise of

@@ -34,8 +29,17 @@ * the persisted instance data.

return entity(spec)
.then(introduce)
.then(mq.insert)
return q(spec)
.then(model.train)
.then(entityp.introduce)
.then(mongocoll.insert)
.then(u.first)
.then(clean);
.then(entityp.moclean);
}
};
/* get a list of entities. Return a promise of the fetched instance data.
*/
exports.list = function () {
return mongocoll.find()
.then(entityp.moclean); // an array of instances
};