Upgrade eslint-config to 7.x
Also upgrade eslint itself to 3.x.
This commit is contained in:
parent
66c54a9646
commit
454bf93aaf
|
@ -2581,7 +2581,7 @@ DataAccessObject.updateAll = function(where, data, options, cb) {
|
|||
}
|
||||
|
||||
function updateCallback(err, info) {
|
||||
if (err) return cb (err);
|
||||
if (err) return cb(err);
|
||||
|
||||
var context = {
|
||||
Model: Model,
|
||||
|
@ -2603,7 +2603,7 @@ DataAccessObject.updateAll = function(where, data, options, cb) {
|
|||
options: options,
|
||||
};
|
||||
Model.notifyObserversOf('persist', context, function(err, ctx) {
|
||||
if (err) return cb (err);
|
||||
if (err) return cb(err);
|
||||
|
||||
if (connector.update.length === 5) {
|
||||
connector.update(Model.modelName, where, data, options, updateCallback);
|
||||
|
|
106
lib/include.js
106
lib/include.js
|
@ -93,12 +93,12 @@ function lookupModel(models, modelName) {
|
|||
* @param callback
|
||||
*/
|
||||
function execTasksWithInterLeave(tasks, callback) {
|
||||
//let's give others some time to process.
|
||||
//Context Switch BEFORE Heavy Computation
|
||||
// let's give others some time to process.
|
||||
// Context Switch BEFORE Heavy Computation
|
||||
process.nextTick(function() {
|
||||
//Heavy Computation
|
||||
// Heavy Computation
|
||||
async.parallel(tasks, function(err, info) {
|
||||
//Context Switch AFTER Heavy Computation
|
||||
// Context Switch AFTER Heavy Computation
|
||||
process.nextTick(function() {
|
||||
callback(err, info);
|
||||
});
|
||||
|
@ -274,7 +274,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
subInclude = scope.include();
|
||||
} else {
|
||||
subInclude = include[relationName];
|
||||
//when include = {user:true}, it does not have subInclude
|
||||
// when include = {user:true}, it does not have subInclude
|
||||
if (subInclude === true) {
|
||||
subInclude = null;
|
||||
}
|
||||
|
@ -290,11 +290,11 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return;
|
||||
}
|
||||
var polymorphic = relation.polymorphic;
|
||||
//if (polymorphic && !polymorphic.discriminator) {
|
||||
// if (polymorphic && !polymorphic.discriminator) {
|
||||
// cb(new Error('Relation "' + relationName + '" is polymorphic but ' +
|
||||
// 'discriminator is not present'));
|
||||
// return;
|
||||
//}
|
||||
// }
|
||||
if (!relation.modelTo) {
|
||||
if (!relation.polymorphic) {
|
||||
cb(new Error(g.f('{{Relation.modelTo}} is not defined for relation %s and is no {{polymorphic}}',
|
||||
|
@ -307,7 +307,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
if (relation.options.disableInclude) {
|
||||
return cb();
|
||||
}
|
||||
//prepare filter and fields for making DB Call
|
||||
// prepare filter and fields for making DB Call
|
||||
var filter = (scope && scope.conditions()) || {};
|
||||
if ((relation.multiple || relation.type === 'belongsTo') && scope) {
|
||||
var includeScope = {};
|
||||
|
@ -324,9 +324,9 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
}
|
||||
utils.mergeQuery(filter, includeScope, {fields: false});
|
||||
}
|
||||
//Let's add a placeholder where query
|
||||
// Let's add a placeholder where query
|
||||
filter.where = filter.where || {};
|
||||
//if fields are specified, make sure target foreign key is present
|
||||
// if fields are specified, make sure target foreign key is present
|
||||
var fields = filter.fields;
|
||||
if (Array.isArray(fields) && fields.indexOf(relation.keyTo) === -1) {
|
||||
fields.push(relation.keyTo);
|
||||
|
@ -339,25 +339,25 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
//
|
||||
if (relation.multiple) {
|
||||
if (relation.modelThrough) {
|
||||
//hasManyThrough needs separate handling
|
||||
// hasManyThrough needs separate handling
|
||||
return includeHasManyThrough(cb);
|
||||
}
|
||||
//This will also include embedsMany with belongsTo.
|
||||
//Might need to optimize db calls for this.
|
||||
// This will also include embedsMany with belongsTo.
|
||||
// Might need to optimize db calls for this.
|
||||
if (relation.type === 'embedsMany') {
|
||||
//embedded docs are part of the objects, no need to make db call.
|
||||
//proceed as implemented earlier.
|
||||
// embedded docs are part of the objects, no need to make db call.
|
||||
// proceed as implemented earlier.
|
||||
return includeEmbeds(cb);
|
||||
}
|
||||
if (relation.type === 'referencesMany') {
|
||||
return includeReferencesMany(cb);
|
||||
}
|
||||
|
||||
//This handles exactly hasMany. Fast and straightforward. Without parallel, each and other boilerplate.
|
||||
// This handles exactly hasMany. Fast and straightforward. Without parallel, each and other boilerplate.
|
||||
if (relation.type === 'hasMany' && relation.multiple && !subInclude) {
|
||||
return includeHasManySimple(cb);
|
||||
}
|
||||
//assuming all other relations with multiple=true as hasMany
|
||||
// assuming all other relations with multiple=true as hasMany
|
||||
return includeHasMany(cb);
|
||||
} else {
|
||||
if (polymorphic) {
|
||||
|
@ -369,7 +369,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
if (relation.type === 'embedsOne') {
|
||||
return includeEmbeds(cb);
|
||||
}
|
||||
//hasOne or belongsTo
|
||||
// hasOne or belongsTo
|
||||
return includeOneToOne(cb);
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
*/
|
||||
function includeHasManyThrough(callback) {
|
||||
var sourceIds = [];
|
||||
//Map for Indexing objects by their id for faster retrieval
|
||||
// Map for Indexing objects by their id for faster retrieval
|
||||
var objIdMap = {};
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
|
@ -395,8 +395,8 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
defineCachedRelations(obj);
|
||||
obj.__cachedRelations[relationName] = [];
|
||||
}
|
||||
//default filters are not applicable on through model. should be applied
|
||||
//on modelTo later in 2nd DB call.
|
||||
// default filters are not applicable on through model. should be applied
|
||||
// on modelTo later in 2nd DB call.
|
||||
var throughFilter = {
|
||||
where: {},
|
||||
};
|
||||
|
@ -404,8 +404,8 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
inq: uniq(sourceIds),
|
||||
};
|
||||
if (polymorphic) {
|
||||
//handle polymorphic hasMany (reverse) in which case we need to filter
|
||||
//by discriminator to filter other types
|
||||
// handle polymorphic hasMany (reverse) in which case we need to filter
|
||||
// by discriminator to filter other types
|
||||
throughFilter.where[polymorphic.discriminator] =
|
||||
relation.modelFrom.definition.name;
|
||||
}
|
||||
|
@ -432,24 +432,24 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
var throughObj = throughObjs[i];
|
||||
var targetId = throughObj[relation.keyThrough];
|
||||
if (targetId) {
|
||||
//save targetIds for 2nd DB Call
|
||||
// save targetIds for 2nd DB Call
|
||||
targetIds.push(targetId);
|
||||
var sourceObj = objIdMap[throughObj[relation.keyTo]];
|
||||
var targetIdStr = targetId.toString();
|
||||
//Since targetId can be duplicates, multiple source objs are put
|
||||
//into buckets.
|
||||
// Since targetId can be duplicates, multiple source objs are put
|
||||
// into buckets.
|
||||
var objList = targetObjsMap[targetIdStr] =
|
||||
targetObjsMap[targetIdStr] || [];
|
||||
objList.push(sourceObj);
|
||||
}
|
||||
}
|
||||
//Polymorphic relation does not have idKey of modelTo. Find it manually
|
||||
// Polymorphic relation does not have idKey of modelTo. Find it manually
|
||||
var modelToIdName = idName(relation.modelTo);
|
||||
filter.where[modelToIdName] = {
|
||||
inq: uniq(targetIds),
|
||||
};
|
||||
|
||||
//make sure that the modelToIdName is included if fields are specified
|
||||
// make sure that the modelToIdName is included if fields are specified
|
||||
if (Array.isArray(fields) && fields.indexOf(modelToIdName) === -1) {
|
||||
fields.push(modelToIdName);
|
||||
} else if (isPlainObject(fields) && !fields[modelToIdName]) {
|
||||
|
@ -468,14 +468,14 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return callback(err);
|
||||
}
|
||||
var tasks = [];
|
||||
//simultaneously process subIncludes. Call it first as it is an async
|
||||
//process.
|
||||
// simultaneously process subIncludes. Call it first as it is an async
|
||||
// process.
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
relation.modelTo.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
//process & link each target with object
|
||||
// process & link each target with object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
async.each(targets, linkManyToMany, next);
|
||||
|
@ -502,7 +502,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
function includeReferencesMany(callback) {
|
||||
var modelToIdName = idName(relation.modelTo);
|
||||
var allTargetIds = [];
|
||||
//Map for Indexing objects by their id for faster retrieval
|
||||
// Map for Indexing objects by their id for faster retrieval
|
||||
var targetObjsMap = {};
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
|
@ -515,7 +515,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
// Please note obj is a plain object at this point
|
||||
targetIds = JSON.parse(targetIds);
|
||||
}
|
||||
//referencesMany has multiple targetIds per obj. We need to concat
|
||||
// referencesMany has multiple targetIds per obj. We need to concat
|
||||
// them into allTargetIds before DB Call
|
||||
allTargetIds = allTargetIds.concat(targetIds);
|
||||
for (var j = 0; j < targetIds.length; j++) {
|
||||
|
@ -550,14 +550,14 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return callback(err);
|
||||
}
|
||||
var tasks = [];
|
||||
//simultaneously process subIncludes
|
||||
// simultaneously process subIncludes
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
relation.modelTo.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
targets = utils.sortObjectsByIds(modelToIdName, allTargetIds, targets);
|
||||
//process each target object
|
||||
// process each target object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
async.each(targets, linkManyToMany, next);
|
||||
|
@ -580,7 +580,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
* @param callback
|
||||
*/
|
||||
function includeHasManySimple(callback) {
|
||||
//Map for Indexing objects by their id for faster retrieval
|
||||
// Map for Indexing objects by their id for faster retrieval
|
||||
var objIdMap2 = includeUtils.buildOneToOneIdentityMapWithOrigKeys(objs, relation.keyFrom);
|
||||
|
||||
filter.where[relation.keyTo] = {
|
||||
|
@ -612,7 +612,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
*/
|
||||
function includeHasMany(callback) {
|
||||
var sourceIds = [];
|
||||
//Map for Indexing objects by their id for faster retrieval
|
||||
// Map for Indexing objects by their id for faster retrieval
|
||||
var objIdMap = {};
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
|
@ -647,13 +647,13 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return callback(err);
|
||||
}
|
||||
var tasks = [];
|
||||
//simultaneously process subIncludes
|
||||
// simultaneously process subIncludes
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
relation.modelTo.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
//process each target object
|
||||
// process each target object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
if (targets.length === 0) {
|
||||
|
@ -664,7 +664,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
|
||||
async.each(targets, linkManyToOne, next);
|
||||
function linkManyToOne(target, next) {
|
||||
//fix for bug in hasMany with referencesMany
|
||||
// fix for bug in hasMany with referencesMany
|
||||
var targetIds = [].concat(target[relation.keyTo]);
|
||||
async.each(targetIds, function(targetId, next) {
|
||||
var obj = objIdMap[targetId.toString()];
|
||||
|
@ -698,7 +698,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
*/
|
||||
function includePolymorphicBelongsTo(callback) {
|
||||
var targetIdsByType = {};
|
||||
//Map for Indexing objects by their type and targetId for faster retrieval
|
||||
// Map for Indexing objects by their type and targetId for faster retrieval
|
||||
var targetObjMapByType = {};
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
|
@ -714,8 +714,8 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
targetIds.push(targetId);
|
||||
var targetIdStr = targetId.toString();
|
||||
targetObjsMap[targetIdStr] = targetObjsMap[targetIdStr] || [];
|
||||
//Is belongsTo. Multiple objects can have the same
|
||||
//targetId and therefore map value is an array
|
||||
// Is belongsTo. Multiple objects can have the same
|
||||
// targetId and therefore map value is an array
|
||||
targetObjsMap[targetIdStr].push(obj);
|
||||
}
|
||||
}
|
||||
|
@ -760,13 +760,13 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
}
|
||||
var tasks = [];
|
||||
|
||||
//simultaneously process subIncludes
|
||||
// simultaneously process subIncludes
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
Model.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
//process each target object
|
||||
// process each target object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
var targetObjsMap = targetObjMapByType[modelType];
|
||||
|
@ -792,7 +792,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
*/
|
||||
function includePolymorphicHasOne(callback) {
|
||||
var sourceIds = [];
|
||||
//Map for Indexing objects by their id for faster retrieval
|
||||
// Map for Indexing objects by their id for faster retrieval
|
||||
var objIdMap = {};
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
var obj = objs[i];
|
||||
|
@ -826,13 +826,13 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return callback(err);
|
||||
}
|
||||
var tasks = [];
|
||||
//simultaneously process subIncludes
|
||||
// simultaneously process subIncludes
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
relation.modelTo.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
//process each target object
|
||||
// process each target object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
async.each(targets, linkOneToOne, next);
|
||||
|
@ -896,13 +896,13 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
return callback(err);
|
||||
}
|
||||
var tasks = [];
|
||||
//simultaneously process subIncludes
|
||||
// simultaneously process subIncludes
|
||||
if (subInclude && targets) {
|
||||
tasks.push(function subIncludesTask(next) {
|
||||
relation.modelTo.include(targets, subInclude, options, next);
|
||||
});
|
||||
}
|
||||
//process each target object
|
||||
// process each target object
|
||||
tasks.push(targetLinkingTask);
|
||||
function targetLinkingTask(next) {
|
||||
async.each(targets, linkOneToMany, next);
|
||||
|
@ -978,7 +978,7 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
cb(null, result);
|
||||
}
|
||||
|
||||
//obj.__cachedRelations[relationName] can be null if no data was returned
|
||||
// obj.__cachedRelations[relationName] can be null if no data was returned
|
||||
if (obj.__cachedRelations &&
|
||||
obj.__cachedRelations[relationName] !== undefined) {
|
||||
return setIncludeData(obj.__cachedRelations[relationName],
|
||||
|
@ -987,8 +987,8 @@ Inclusion.include = function(objects, include, options, cb) {
|
|||
|
||||
var inst = (obj instanceof self) ? obj : new self(obj);
|
||||
|
||||
//If related objects are not cached by include Handlers, directly call
|
||||
//related accessor function even though it is not very efficient
|
||||
// If related objects are not cached by include Handlers, directly call
|
||||
// related accessor function even though it is not very efficient
|
||||
var related; // relation accessor function
|
||||
|
||||
if ((relation.multiple || relation.type === 'belongsTo') && scope) {
|
||||
|
|
|
@ -898,9 +898,9 @@ var throughKeys = function(definition) {
|
|||
} else if (definition.modelFrom === definition.modelTo) {
|
||||
return findBelongsTo(modelThrough, definition.modelTo, pk2).
|
||||
sort(function(fk1, fk2) {
|
||||
//Fix for bug - https://github.com/strongloop/loopback-datasource-juggler/issues/571
|
||||
//Make sure that first key is mapped to modelFrom
|
||||
//& second key to modelTo. Order matters
|
||||
// Fix for bug - https://github.com/strongloop/loopback-datasource-juggler/issues/571
|
||||
// Make sure that first key is mapped to modelFrom
|
||||
// & second key to modelTo. Order matters
|
||||
return (definition.keyTo === fk1) ? -1 : 1;
|
||||
});
|
||||
} else {
|
||||
|
@ -1812,7 +1812,7 @@ HasMany.prototype.create = function(targetModelData, options, cb) {
|
|||
|
||||
modelTo.create(targetModelData, options, function(err, targetModel) {
|
||||
if (!err) {
|
||||
//Refresh the cache
|
||||
// Refresh the cache
|
||||
apply(targetModel, self.addToCache.bind(self));
|
||||
cb && cb(err, targetModel);
|
||||
} else {
|
||||
|
|
12
lib/utils.js
12
lib/utils.js
|
@ -120,7 +120,7 @@ function convertToArray(include) {
|
|||
obj[include] = true;
|
||||
return [obj];
|
||||
} else if (isPlainObject(include)) {
|
||||
//if include is of the form - {relation:'',scope:''}
|
||||
// if include is of the form - {relation:'',scope:''}
|
||||
if (include.rel || include.relation) {
|
||||
return [include];
|
||||
}
|
||||
|
@ -178,15 +178,15 @@ function mergeQuery(base, update, spec) {
|
|||
base.include = update.include;
|
||||
} else {
|
||||
if (spec.nestedInclude === true) {
|
||||
//specify nestedInclude=true to force nesting of inclusions on scoped
|
||||
//queries. e.g. In physician.patients.getAsync({include: 'address'}),
|
||||
//inclusion should be on patient model, not on physician model.
|
||||
// specify nestedInclude=true to force nesting of inclusions on scoped
|
||||
// queries. e.g. In physician.patients.getAsync({include: 'address'}),
|
||||
// inclusion should be on patient model, not on physician model.
|
||||
var saved = base.include;
|
||||
base.include = {};
|
||||
base.include[update.include] = saved;
|
||||
} else {
|
||||
//default behaviour of inclusion merge - merge inclusions at the same
|
||||
//level. - https://github.com/strongloop/loopback-datasource-juggler/pull/569#issuecomment-95310874
|
||||
// default behaviour of inclusion merge - merge inclusions at the same
|
||||
// level. - https://github.com/strongloop/loopback-datasource-juggler/pull/569#issuecomment-95310874
|
||||
base.include = mergeIncludes(base.include, update.include);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"async-iterators": "^0.2.2",
|
||||
"eslint": "^3.11.1",
|
||||
"eslint-config-loopback": "^6.0.0",
|
||||
"eslint": "^3.12.2",
|
||||
"eslint-config-loopback": "^7.0.1",
|
||||
"mocha": "^2.1.0",
|
||||
"should": "^8.0.2"
|
||||
},
|
||||
|
|
|
@ -478,7 +478,7 @@ function testOrm(dataSource) {
|
|||
|
||||
/* eslint-disable max-len */
|
||||
it('hasMany should be cached', function(test) {
|
||||
//User.create(function (e, u) {
|
||||
// User.create(function (e, u) {
|
||||
// u.posts.create({}, function (e, p) {
|
||||
// find all posts for a user.
|
||||
// Finding one post with an existing author associated
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
/*global describe,it*/
|
||||
/*jshint expr:true */
|
||||
/* global describe,it */
|
||||
/* jshint expr:true */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -44,7 +44,7 @@ describe('GeoPoint', function() {
|
|||
});
|
||||
|
||||
it('should reject invalid parameters', function() {
|
||||
/*jshint -W024 */
|
||||
/* jshint -W024 */
|
||||
var fn = function() {
|
||||
new GeoPoint('150,-34');
|
||||
};
|
||||
|
|
|
@ -841,11 +841,11 @@ describe('include', function() {
|
|||
result.forEach(function(r) {
|
||||
assemblies[r.name] = r;
|
||||
});
|
||||
//sedan
|
||||
// sedan
|
||||
assemblies.sedan.parts().should.have.length(3);
|
||||
//hatchback
|
||||
// hatchback
|
||||
assemblies.hatchback.parts().should.have.length(2);
|
||||
//SUV
|
||||
// SUV
|
||||
assemblies.SUV.parts().should.have.length(0);
|
||||
self.called.should.eql(3);
|
||||
done();
|
||||
|
|
|
@ -95,11 +95,11 @@ describe('manipulation', function() {
|
|||
|
||||
it('should create instance (promise variant)', function(done) {
|
||||
Person.create({name: 'Anatoliy'})
|
||||
.then (function(p) {
|
||||
.then(function(p) {
|
||||
p.name.should.equal('Anatoliy');
|
||||
should.exist(p);
|
||||
return Person.findById(p.id)
|
||||
.then (function(person) {
|
||||
.then(function(person) {
|
||||
person.id.should.eql(p.id);
|
||||
person.name.should.equal('Anatoliy');
|
||||
done();
|
||||
|
@ -125,7 +125,7 @@ describe('manipulation', function() {
|
|||
p.name.should.equal('Anatoliy');
|
||||
p.isNewRecord().should.be.true;
|
||||
p.save()
|
||||
.then (function(inst) {
|
||||
.then(function(inst) {
|
||||
inst.isNewRecord().should.be.false;
|
||||
inst.should.equal(p);
|
||||
done();
|
||||
|
@ -156,7 +156,7 @@ describe('manipulation', function() {
|
|||
|
||||
it('should not allow user-defined value for the id of object - create (promise variant)', function(done) {
|
||||
Person.create({id: 123456})
|
||||
.then (function(p) {
|
||||
.then(function(p) {
|
||||
done(new Error('Person.create should have failed.'));
|
||||
}, function(err) {
|
||||
err.should.be.instanceof(ValidationError);
|
||||
|
@ -184,7 +184,7 @@ describe('manipulation', function() {
|
|||
var p = new Person({id: 123456});
|
||||
p.isNewRecord().should.be.true;
|
||||
p.save()
|
||||
.then (function(inst) {
|
||||
.then(function(inst) {
|
||||
done(new Error('save should have failed.'));
|
||||
}, function(err) {
|
||||
err.should.be.instanceof(ValidationError);
|
||||
|
@ -223,11 +223,11 @@ describe('manipulation', function() {
|
|||
|
||||
it('should create instance with blank data (promise variant)', function(done) {
|
||||
Person.create()
|
||||
.then (function(p) {
|
||||
.then(function(p) {
|
||||
should.exist(p);
|
||||
should.not.exists(p.name);
|
||||
return Person.findById(p.id)
|
||||
.then (function(person) {
|
||||
.then(function(person) {
|
||||
person.id.should.eql(p.id);
|
||||
should.not.exists(person.name);
|
||||
done();
|
||||
|
|
|
@ -65,12 +65,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
return callCreate().then(function(result) {
|
||||
hookMonitor.names.should.eql([
|
||||
'Embedded:before save',
|
||||
//TODO 'Embedded:persist',
|
||||
// TODO 'Embedded:persist',
|
||||
'Owner:before save',
|
||||
'Owner:persist',
|
||||
'Owner:loaded',
|
||||
'Owner:after save',
|
||||
//TODO 'Embedded:loaded',
|
||||
// TODO 'Embedded:loaded',
|
||||
'Embedded:after save',
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -82,12 +82,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
return callUpdate().then(function(result) {
|
||||
hookMonitor.names.should.eql([
|
||||
'Embedded:before save',
|
||||
//TODO 'Embedded:persist',
|
||||
// TODO 'Embedded:persist',
|
||||
'Owner:before save',
|
||||
'Owner:persist',
|
||||
'Owner:loaded',
|
||||
'Owner:after save',
|
||||
//TODO 'Embedded:loaded',
|
||||
// TODO 'Embedded:loaded',
|
||||
'Embedded:after save',
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -65,12 +65,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
return callCreate().then(function(result) {
|
||||
hookMonitor.names.should.eql([
|
||||
'Embedded:before save',
|
||||
//TODO 'Embedded:persist',
|
||||
// TODO 'Embedded:persist',
|
||||
'Owner:before save',
|
||||
'Owner:persist',
|
||||
'Owner:loaded',
|
||||
'Owner:after save',
|
||||
//TODO 'Embedded:loaded',
|
||||
// TODO 'Embedded:loaded',
|
||||
'Embedded:after save',
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -72,12 +72,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
return callUpdate().then(function(result) {
|
||||
hookMonitor.names.should.eql([
|
||||
'Embedded:before save',
|
||||
//TODO 'Embedded:persist',
|
||||
// TODO 'Embedded:persist',
|
||||
'Owner:before save',
|
||||
'Owner:persist',
|
||||
'Owner:loaded',
|
||||
'Owner:after save',
|
||||
//TODO 'Embedded:loaded',
|
||||
// TODO 'Embedded:loaded',
|
||||
'Embedded:after save',
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -92,9 +92,9 @@ describe('relations', function() {
|
|||
|
||||
it('should create record on scope with promises', function(done) {
|
||||
Book.create()
|
||||
.then (function(book) {
|
||||
.then(function(book) {
|
||||
return book.chapters.create()
|
||||
.then (function(c) {
|
||||
.then(function(c) {
|
||||
should.exist(c);
|
||||
c.bookId.should.eql(book.id);
|
||||
done();
|
||||
|
|
|
@ -338,7 +338,7 @@ describe('util.mergeIncludes', function() {
|
|||
|
||||
it('Merge includes with and without relation syntax properly',
|
||||
function() {
|
||||
//w & w/o relation syntax - no collision
|
||||
// w & w/o relation syntax - no collision
|
||||
var baseInclude = ['relation2'];
|
||||
var updateInclude = {
|
||||
relation: 'relation1',
|
||||
|
@ -350,14 +350,14 @@ describe('util.mergeIncludes', function() {
|
|||
}, {relation2: true}];
|
||||
checkInputOutput(baseInclude, updateInclude, expectedInclude);
|
||||
|
||||
//w & w/o relation syntax - collision
|
||||
// w & w/o relation syntax - collision
|
||||
baseInclude = ['relation1'];
|
||||
updateInclude = {relation: 'relation1', scope: {include: 'relation2'}};
|
||||
expectedInclude =
|
||||
[{relation: 'relation1', scope: {include: 'relation2'}}];
|
||||
checkInputOutput(baseInclude, updateInclude, expectedInclude);
|
||||
|
||||
//w & w/o relation syntax - collision
|
||||
// w & w/o relation syntax - collision
|
||||
baseInclude = {relation: 'relation1', scope: {include: 'relation2'}};
|
||||
updateInclude = ['relation1'];
|
||||
expectedInclude = [{relation1: true}];
|
||||
|
|
Loading…
Reference in New Issue