Merge pull request #41 from strongloop/feature/rename-all-to-find
Replace all with find to make it consistent
This commit is contained in:
commit
303be5882b
|
@ -30,9 +30,14 @@ Customer.hasMany(Order, {as: 'orders', foreignKey: 'customerId'});
|
||||||
Customer.create({name: 'Ray'}, function (err, customer) {
|
Customer.create({name: 'Ray'}, function (err, customer) {
|
||||||
Order.create({customerId: customer.id, orderDate: new Date()}, function (err, order) {
|
Order.create({customerId: customer.id, orderDate: new Date()}, function (err, order) {
|
||||||
customer.orders(console.log);
|
customer.orders(console.log);
|
||||||
customer.orders.create({orderDate: new Date()}, console.log);
|
customer.orders.create({orderDate: new Date()}, function(err, order) {
|
||||||
customer.orders.findById('2', console.log);
|
console.log(order);
|
||||||
customer.orders.destroy('2', console.log);
|
Customer.include([customer], 'orders', function(err, results) {
|
||||||
|
console.log('Results: ', results);
|
||||||
|
});
|
||||||
|
customer.orders.findById('2', console.log);
|
||||||
|
customer.orders.destroy('2', console.log);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ Inclusion.include = function (objects, include, cb) {
|
||||||
req['include'] = subInclude;
|
req['include'] = subInclude;
|
||||||
|
|
||||||
return function(cb) {
|
return function(cb) {
|
||||||
relation.modelTo.all(req, function(err, objsIncluded) {
|
relation.modelTo.find(req, function(err, objsIncluded) {
|
||||||
for (var i = 0; i < objsIncluded.length; i++) {
|
for (var i = 0; i < objsIncluded.length; i++) {
|
||||||
delete keysToBeProcessed[objsIncluded[i][relation.keyTo]];
|
delete keysToBeProcessed[objsIncluded[i][relation.keyTo]];
|
||||||
var objectsFrom = objsByKeys[relation.keyFrom][objsIncluded[i][relation.keyTo]];
|
var objectsFrom = objsByKeys[relation.keyFrom][objsIncluded[i][relation.keyTo]];
|
||||||
|
|
|
@ -55,7 +55,7 @@ Relation.hasMany = function hasMany(anotherClass, params) {
|
||||||
};
|
};
|
||||||
// each instance of this class should have method named
|
// each instance of this class should have method named
|
||||||
// pluralize(anotherClass.modelName)
|
// pluralize(anotherClass.modelName)
|
||||||
// which is actually just anotherClass.all({where: {thisModelNameId: this[idName]}}, cb);
|
// which is actually just anotherClass.find({where: {thisModelNameId: this[idName]}}, cb);
|
||||||
var scopeMethods = {
|
var scopeMethods = {
|
||||||
findById: find,
|
findById: find,
|
||||||
destroy: destroy
|
destroy: destroy
|
||||||
|
|
|
@ -139,7 +139,7 @@ function defineScope(cls, targetClass, name, params, methods) {
|
||||||
- If fetching the Elements on which destroyAll is called results in an error
|
- If fetching the Elements on which destroyAll is called results in an error
|
||||||
*/
|
*/
|
||||||
function destroyAll(cb) {
|
function destroyAll(cb) {
|
||||||
targetClass.all(this._scope, function (err, data) {
|
targetClass.find(this._scope, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(err);
|
cb(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue