Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign 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

Promise functions for working with model entities

Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Entity Promises

Promise functions for working with entity models.

Functions

  • 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

Example:

var entityp     = require("entity-promises"),
    u           = require("underscore"),
    mongocoll   = ...,
    introduce,
    clean;

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
 * the persisted instance data. 
 */
exports.create = function (spec) {

    return entity(spec)
        .then(introduce)
        .then(mq.insert)
        .then(u.first)
        .then(clean);

}

Keywords

q

FAQs

Package last updated on 30 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts