Comparing version 1.3.3 to 1.3.4
@@ -35,3 +35,3 @@ /** | ||
return function (instanceProps, staticProps) { | ||
console.error("MONGORITO Model.extend() function is deprecated and will be removed really, really soon. Please, use ES6 classes to define your models (example on https://github.com/vdemedes/mongorito)."); | ||
console.error('MONGORITO Model.extend() function is deprecated and will be removed really, really soon. Please, use ES6 classes to define your models (example on https://github.com/vdemedes/mongorito).'); | ||
@@ -38,0 +38,0 @@ var klass = function klass() { |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
/** | ||
@@ -5,4 +7,2 @@ * Dependencies | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
@@ -18,5 +18,5 @@ | ||
const result = require('lodash.result'); | ||
const clone = require('clone'); | ||
const monk = require('monk'); | ||
const wrap = require('co-monk'); | ||
const copy = require('copy-to'); | ||
const _get = require('get-value'); | ||
@@ -109,3 +109,3 @@ const _set = require('set-value'); | ||
return Mongorito; | ||
})(); | ||
})() | ||
@@ -118,2 +118,4 @@ /** | ||
; | ||
Mongorito._collections = {}; | ||
@@ -127,11 +129,11 @@ | ||
function Model() { | ||
var attrs = arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments[1] === undefined ? {} : arguments[1]; | ||
var attrs = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
_classCallCheck(this, Model); | ||
this.attributes = attrs; | ||
this.attributes = clone(attrs); | ||
this.changed = {}; | ||
this.previous = {}; | ||
this.options = options; | ||
this.options = clone(options); | ||
@@ -162,2 +164,8 @@ // reset hooks | ||
/** | ||
* Get collection for current model | ||
* | ||
* @api private | ||
*/ | ||
/** | ||
* Get model attribute | ||
@@ -176,3 +184,3 @@ * | ||
// return a deep copy | ||
return value && value.constructor === Object ? copy(value).to({}) : value; | ||
return value && value.constructor === Object ? clone(value) : value; | ||
}; | ||
@@ -223,2 +231,13 @@ | ||
/** | ||
* Unset model attribute | ||
* | ||
* @param {String} key - property name | ||
* @api public | ||
*/ | ||
Model.prototype.unset = function unset(key) { | ||
this.set(key, undefined); | ||
}; | ||
/** | ||
* Set default values | ||
@@ -411,3 +430,3 @@ * | ||
var options = arguments[2] === undefined ? {} : arguments[2]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
@@ -601,2 +620,8 @@ var hooks = this._getHooks(when, action); | ||
/** | ||
* Get database for a model | ||
* | ||
* @api private | ||
*/ | ||
/** | ||
* Find documents | ||
@@ -686,5 +711,5 @@ * | ||
Model.index = function* index() { | ||
var _collection; | ||
var _collection2; | ||
return yield (_collection = this._collection).index.apply(_collection, arguments); | ||
return yield (_collection2 = this._collection).index.apply(_collection2, arguments); | ||
}; | ||
@@ -705,10 +730,3 @@ | ||
key: '_collection', | ||
/** | ||
* Get collection for current model | ||
* | ||
* @api private | ||
*/ | ||
get: function () { | ||
get: function get() { | ||
if (is.string(this.collection)) { | ||
@@ -730,4 +748,2 @@ return Mongorito._collection(this._db, this.collection); | ||
} | ||
}, { | ||
key: '_db', | ||
@@ -740,3 +756,5 @@ /** | ||
get: function () { | ||
}, { | ||
key: '_db', | ||
get: function get() { | ||
// use either custom database | ||
@@ -749,10 +767,3 @@ // specified for this model | ||
key: '_db', | ||
/** | ||
* Get database for a model | ||
* | ||
* @api private | ||
*/ | ||
get: function () { | ||
get: function get() { | ||
// support for multiple connections | ||
@@ -763,4 +774,2 @@ // if model has a custom database assigned | ||
} | ||
}, { | ||
key: '_collection', | ||
@@ -773,3 +782,5 @@ /** | ||
get: function () { | ||
}, { | ||
key: '_collection', | ||
get: function get() { | ||
if (is.string(this.prototype.collection)) { | ||
@@ -794,3 +805,3 @@ return Mongorito._collection(this._db, this.prototype.collection); | ||
return Model; | ||
})(); | ||
})() | ||
@@ -800,2 +811,4 @@ // Setting up functions that have | ||
// and act as a bridge to Query | ||
; | ||
const methods = ['where', 'limit', 'skip', 'sort', 'exists', 'lt', 'lte', 'gt', 'gte', 'in', 'nin', 'and', 'or', 'ne', 'nor', 'populate', 'matches', 'match', 'include', 'exclude', 'search']; | ||
@@ -802,0 +815,0 @@ |
@@ -9,3 +9,3 @@ /** | ||
const assign = Object.assign || require('object.assign'); | ||
const assign = Object.assign || require('object-assign'); | ||
const is = require('is_js'); | ||
@@ -390,6 +390,8 @@ | ||
return Query; | ||
})(); | ||
})() | ||
// Setting up functions that | ||
// have the same implementation | ||
; | ||
const methods = ['lt', 'lte', 'gt', 'gte', 'in', 'nin', 'ne']; | ||
@@ -396,0 +398,0 @@ |
{ | ||
"name": "mongorito", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "ES6 generator-based MongoDB ODM. It rocks.", | ||
@@ -8,4 +8,4 @@ "author": "Vadim Demedes <vdemedes@gmail.com>", | ||
"bson": "^0.3.2", | ||
"clone": "^1.0.2", | ||
"co-monk": "^1.0.0", | ||
"copy-to": "^2.0.1", | ||
"get-value": "^1.1.5", | ||
@@ -16,3 +16,3 @@ "is_js": "^0.7.4", | ||
"monk": "^1.0.1", | ||
"object.assign": "^3.0.1", | ||
"object-assign": "^3.0.0", | ||
"pluralize": "^1.1.2", | ||
@@ -22,3 +22,3 @@ "set-value": "^0.2.0" | ||
"devDependencies": { | ||
"babel": "^5.6.14", | ||
"babel": "^5.8.3", | ||
"chai": "^3.0.0", | ||
@@ -25,0 +25,0 @@ "chance": "^0.7.6", |
32453
1053
+ Addedclone@^1.0.2
+ Addedobject-assign@^3.0.0
+ Addedclone@1.0.4(transitive)
+ Addedobject-assign@3.0.0(transitive)
- Removedcopy-to@^2.0.1
- Removedobject.assign@^3.0.1
- Removedcopy-to@2.0.1(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@3.0.1(transitive)