node-entity
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -7,3 +7,3 @@ /** | ||
var __ = require('lodash'); | ||
var EntityCrud = require('../entity'); | ||
var EntityCrud = require('../entity-crud'); | ||
@@ -10,0 +10,0 @@ /** |
108
entity.js
@@ -0,1 +1,3 @@ | ||
/*jshint unused:false */ | ||
/** | ||
@@ -9,116 +11,12 @@ * @fileOverview The Entity base class. | ||
var midd = require('middlewarify'); | ||
/** | ||
* The base Entity Class all entities extend from. | ||
* | ||
* @param {Object=} optUdo Optionally define the current handling user. | ||
* @constructor | ||
* @extends {events.EventEmitter} | ||
*/ | ||
var Entity = module.exports = function(optUdo) { | ||
var Entity = module.exports = function() { | ||
EventEmitter.call(this); | ||
/** @type {?Object} The current user or null for anonymous */ | ||
this.udo = optUdo || null; | ||
// Create primitive middlewares | ||
midd.make(this, 'create', this._create.bind(this)); | ||
midd.make(this, 'read', this._read.bind(this)); | ||
midd.make(this, 'readOne', this._readOne.bind(this)); | ||
midd.make(this, 'readLimit', this._readLimit.bind(this)); | ||
midd.make(this, 'update', this._update.bind(this)); | ||
midd.make(this, 'delete', this._delete.bind(this)); | ||
midd.make(this, 'count', this._count.bind(this)); | ||
}; | ||
util.inherits(Entity, EventEmitter); | ||
/** | ||
* Set the current user data object | ||
* @param {Object} udo A User Data Object. | ||
*/ | ||
Entity.prototype.setUdo = function(udo) { | ||
this.udo = udo; | ||
}; | ||
/** | ||
* Create an entity item. | ||
* | ||
* @param {Object} itemData The data to use for creating. | ||
* @param {Function(Error=, Object=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._create = function(itemData, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Read one entity item. | ||
* | ||
* @param {string|Object} id the item id or an Object to query against. | ||
* @param {Function(Error=, Object=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._readOne = function(id, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Read items based on query or if not defined, read all items. | ||
* Do practice common sense! | ||
* | ||
* @param {Object|string=} optQuery Optionally define a query to limit results. | ||
* @param {Function(Error=, Object=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._read = function(optQuery, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Read a limited set of items. | ||
* | ||
* @param {?Object} query Narrow down the set, set to null for all. | ||
* @param {number} skip starting position. | ||
* @param {number} limit how many records to fetch. | ||
* @param {Function(Error=, Array.<Object>=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._readLimit = function(query, skip, limit, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Get the count of items. | ||
* | ||
* @param {?Object} query Narrow down the set, set to null for all. | ||
* @param {Function(Error=, number=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._count = function(query, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Update an entity item. | ||
* | ||
* @param {string} id the item id. | ||
* @param {Object} itemData The data to use for creating. | ||
* @param {Function(Error=, Object=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._update = function(id, itemData, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
/** | ||
* Remove an entity item. | ||
* | ||
* @param {string} id the item id. | ||
* @param {Function(Error=, Object=)} done callback. | ||
* @protected | ||
*/ | ||
Entity.prototype._delete = function(id, done) { | ||
throw new Error('Not Implemented'); | ||
}; | ||
@@ -5,2 +5,4 @@ /** | ||
module.exports = require('./entity'); | ||
var Entity = module.exports = require('./entity'); | ||
Entity.Mongoose = require('./drivers/mongoose.drv'); |
{ | ||
"name": "node-entity", | ||
"description": "The MVCe implementation for Node.js", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/thanpolas/entity", | ||
@@ -34,3 +34,2 @@ "author": { | ||
"lodash": "~1.3.1", | ||
"async": "~0.2.9", | ||
"middlewarify": "~0.0.2" | ||
@@ -43,3 +42,5 @@ }, | ||
}, | ||
"peerDependencies": {}, | ||
"peerDependencies": { | ||
"mongoose": "~3.6.20" | ||
}, | ||
"keywords": [ | ||
@@ -46,0 +47,0 @@ "entity", |
@@ -7,3 +7,2 @@ /** | ||
var Entity = require('../..'); | ||
var MongDrv = require('../../drivers/mongoose.drv'); | ||
var testEntity = require('./entity.test'); | ||
@@ -21,3 +20,3 @@ var testDrivers = require('./drivers.test'); | ||
var drivers = [ | ||
MongDrv, // test major num: 2 | ||
Entity.Mongoose, // test major num: 2 | ||
]; | ||
@@ -47,7 +46,5 @@ | ||
}); | ||
}; | ||
// ignite | ||
core.init(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23348
16
592
+ Addedbson@0.2.2(transitive)
+ Addedhooks@0.2.1(transitive)
+ Addedkerberos@0.0.3(transitive)
+ Addedmongodb@1.3.19(transitive)
+ Addedmongoose@3.6.20(transitive)
+ Addedmpath@0.1.1(transitive)
+ Addedmpromise@0.2.1(transitive)
+ Addedms@0.1.0(transitive)
+ Addedmuri@0.3.1(transitive)
+ Addedregexp-clone@0.0.1(transitive)
+ Addedsliced@0.0.40.0.5(transitive)
- Removedasync@~0.2.9