Comparing version 0.3.12 to 0.3.13
@@ -220,3 +220,6 @@ 'use strict'; | ||
value: function join(joinFn) { | ||
return this.joinEach(joinFn); | ||
(0, _invariant2['default'])(typeof joinFn === 'function', 'join(...): argument must be a function'); | ||
this.addPipeline(PIPELINE_TYPE.Join, joinFn); | ||
return this; | ||
} | ||
@@ -223,0 +226,0 @@ }, { |
@@ -193,3 +193,9 @@ import _each from 'lodash/collection/each'; | ||
join(joinFn) { | ||
return this.joinEach(joinFn); | ||
invariant( | ||
typeof joinFn === 'function', | ||
'join(...): argument must be a function' | ||
); | ||
this.addPipeline(PIPELINE_TYPE.Join, joinFn); | ||
return this; | ||
} | ||
@@ -196,0 +202,0 @@ |
{ | ||
"name": "marsdb", | ||
"version": "0.3.12", | ||
"version": "0.3.13", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Artem Artemev", |
@@ -325,8 +325,29 @@ import Collection from '../../lib/Collection'; | ||
describe('#join', function () { | ||
it('should use joinEach for an array', function () { | ||
return db.find().join(d => { | ||
d.should.be.an('object'); | ||
}).then((result) => { | ||
result.should.be.an('array'); | ||
}); | ||
}); | ||
it('should use joinAll for single object', function () { | ||
return db.findOne().join(d => { | ||
d.should.be.an('object'); | ||
}).then((result) => { | ||
result.should.be.an('object'); | ||
}); | ||
}); | ||
it('should throw an error if join is not a function', function () { | ||
const cursor = new Cursor(db); | ||
(() => cursor.join(123)).should.throw(Error); | ||
}); | ||
}); | ||
describe('#joinEach', function () { | ||
it('should join by function with promises', function () { | ||
const cursor = new Cursor(db); | ||
cursor.find().sort({b: 1}).join(d => { | ||
cursor.find().sort({b: 1}).joinEach(d => { | ||
const cursor2 = new Cursor(db); | ||
@@ -346,3 +367,3 @@ return cursor2.find({g: d.g}).exec().then((result) => { | ||
it('should not change object in a storage', function () { | ||
return db.find().sort({b: 1}).join(d => { | ||
return db.find().sort({b: 1}).joinEach(d => { | ||
return db.find({g: d.g}).then((result) => { | ||
@@ -349,0 +370,0 @@ d.groupObjs = result; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1083160
25288