Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-entity

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-entity - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

3

adaptors/mongoose.adp.js

@@ -7,2 +7,3 @@ /**

var Promise = require('bluebird');
var mongoose = require('mongoose');

@@ -318,3 +319,3 @@ var AdaptorBase = require('./base.adp');

__.forIn(query, function(value, key) {
if (__.isObject(value)) {
if (__.isObject(value) && !(value instanceof mongoose.Types.ObjectId)) {
result.selectors[key] = value;

@@ -321,0 +322,0 @@ } else {

@@ -8,9 +8,5 @@ /*jshint camelcase:false */

module.exports = function( grunt ) {
'use strict';
var pkg = grunt.file.readJSON('package.json');
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-services');
//

@@ -24,5 +20,10 @@ // Grunt configuration:

//
pkg: pkg,
jshint: {
options: {
jshintrc: true,
},
backend: ['lib/**/*.js'],
},

@@ -29,0 +30,0 @@ release: {

{
"name": "node-entity",
"description": "The MVCe implementation for Node.js",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/thanpolas/entity",

@@ -31,3 +31,3 @@ "author": {

"scripts": {
"test": "node_modules/.bin/mocha -u tdd -R spec test/unit"
"test": "./node_modules/.bin/grunt jshint && node_modules/.bin/mocha -u tdd -R spec test/unit"
},

@@ -50,3 +50,6 @@ "dependencies": {

"grunt-services": "0.0.2",
"sequelize": "~1.7.9"
"sequelize": "~1.7.9",
"grunt-contrib-jshint": "^0.10.0",
"load-grunt-tasks": "^0.6.0",
"grunt-cli": "^0.1.13"
},

@@ -53,0 +56,0 @@ "peerDependencies": {},

# Entity
An Entity is a business unit. Entities are supersets of models, resources and contain the business logic. They are persistent storage agnostic and provide a normalized API with which your consuming services can perform business logic actions.
An Entity is a high level business unit. Entities are supersets of models and resources. They are persistent storage agnostic and provide a normalized CRUD API with which your consuming services can perform business logic actions.

@@ -11,3 +11,3 @@ ![Entity Figure 1](https://docs.google.com/drawings/d/1gCV3jmHVK8jJcH40dmUJ6-iZU9YdKixW9YPQ5kHj-As/pub?w=331&h=289)

Currently the CRUD interface has been implemented and two ORM packages are supported in the form of Adaptors, [Mongoose][] and [Sequelize][].
Entities come with a normalized CRUD interface which plugs into [now] two ORM packages, [Mongoose][] and [Sequelize][].

@@ -22,3 +22,3 @@ ## Install

Entity uses the [Cip][] package for inheritance, it implements the pseudo-classical inheritance pattern packed in a convenient and easy to use API. Extend will create a new Constructor that can be invoked with the `new` keyword or itself extended using the same static method. All the static methods related to inheritance are from Cip.
Entity uses the [Cip][] package for inheritance, it implements the pseudo-classical inheritance pattern packed in a convenient and easy to use API.

@@ -48,10 +48,17 @@ ### entity.extend()

```
Read more about [extend() at Cip's documentation](https://github.com/thanpolas/cip#extend-create-a-new-constructor).
### entity.getInstance()
### entity.extendSingleton()
The `getInstance()` method will return a singleton instance. This means that you will get the same exact instance every time you invoke this static function.
Use the `extendSingleton()` method to create singleton constructors, use the `getInstance()` method to always get the same exact instance of the entity.
```js
var entityChild = require('../entities/child.ent').getInstance();
var entity = require('entity');
var UserEntity = entity.extendSingleton(function() {});
/* ... */
var userEnt = UserEntity.getInstance();
```

@@ -63,3 +70,2 @@

## Entity CRUD Interface

@@ -96,3 +102,4 @@

document.name === 'thanasis'; // true
}, then(function(error) {
})
.catch(function(error) {
// deal with error.

@@ -113,9 +120,11 @@ });

```js
entity.read().then(function(documents) {
// All documents
});
entity.read()
.then(function(documents) {
// All documents
});
entity.read({networkId: '47'}).then(function(documents) {
// All documents whose "networkId" equals 47
});
entity.read({networkId: '47'})
.then(function(documents) {
// All documents whose "networkId" equals 47
});
```

@@ -151,9 +160,11 @@

```js
entity.read({name: 'thanasis'}).then(function(document) {
document.name === 'thanasis'; // true
});
entity.read({name: 'thanasis'})
.then(function(document) {
document.name === 'thanasis'; // true
});
entity.read('42').then(function(document) {
document.id === '42'; // true
});
entity.read('42')
.then(function(document) {
document.id === '42'; // true
});
```

@@ -171,11 +182,13 @@

```js
entity.readLimit(null, 0, 10).then(function(documents) {
// fetched the first 10 items
});
entity.readLimit(null, 0, 10)
.then(function(documents) {
// fetched the first 10 items
});
entity.readLimit({networkId: '42'}, 10, 10).then(function(documents) {
// fetched records whose networkId equels '42
// And started from the 10th item,
// limiting the total records to 10
});
entity.readLimit({networkId: '42'}, 10, 10)
.then(function(documents) {
// fetched records whose networkId equels '42
// And started from the 10th item,
// limiting the total records to 10
});
```

@@ -192,9 +205,11 @@

```js
entity.update('99', {name: 'John').then(function(document) {
document.name === 'John'; // true only for Mongoose
});
entity.update('99', {name: 'John')
.then(function(document) {
document.name === 'John'; // true only for Mongoose
});
entity.update({networkId: '42'}, {isActive: false}).then(function(documents) {
// deactive all items with network id that equals 42
});
entity.update({networkId: '42'}, {isActive: false})
.then(function(documents) {
// deactive all items with network id that equals 42
});
```

@@ -211,9 +226,11 @@ [Check out the `entity.update()` tests](https://github.com/thanpolas/entity/blob/master/test/unit/adaptor-crud-update.test.js)

```js
entity.delete('99').then(function() {
// job done
});
entity.delete('99')
.then(function() {
// job done
});
entity.delete({networkId: '42'}).then(function() {
// all gone
});
entity.delete({networkId: '42'})
.then(function() {
// all gone
});
```

@@ -231,9 +248,11 @@

```js
entity.count().then(function(count) {
typeof count === 'number'; // true, all the items.
});
entity.count()
.then(function(count) {
typeof count === 'number'; // true, all the items.
});
entity.count({networkId: '42'}).then(function() {
typeof count === 'number'; // true
});
entity.count({networkId: '42'})
.then(function() {
typeof count === 'number'; // true
});
```

@@ -519,2 +538,4 @@

- **v0.3.1**, *19 Sep 2014*
- Fixed issue where query selector on mongo adaptor confused ObjectId types with objects.
- **v0.3.0**, *25 Jul 2014*

@@ -521,0 +542,0 @@ - The Middlewarify 0.4.0 may break some existing installations when value is returned on After/ middleware, thus a minor version bump is warranted.

@@ -55,2 +55,9 @@ /**

});
test(majNum + '.5.2.5 Read All records with an empty object', function() {
return ent.read({}).then(function(res) {
assert.equal(res.length, 2, 'There should be two results');
assert.equal(res[0].name, fix.one.name, 'Name should be the same');
});
});
});

@@ -57,0 +64,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc