Fix the example for scope
This commit is contained in:
parent
00972c2f41
commit
97c5cfd644
|
@ -51,7 +51,7 @@ Post.belongsTo(User, {as: 'author', foreignKey: 'userId'});
|
||||||
|
|
||||||
User.hasAndBelongsToMany('groups');
|
User.hasAndBelongsToMany('groups');
|
||||||
|
|
||||||
var user2 = new User({name: 'Smith'});
|
var user2 = new User({name: 'Smith', age: 14});
|
||||||
user2.save(function (err) {
|
user2.save(function (err) {
|
||||||
console.log(user2);
|
console.log(user2);
|
||||||
var post = user2.posts.build({title: 'Hello world'});
|
var post = user2.posts.build({title: 'Hello world'});
|
||||||
|
@ -64,7 +64,7 @@ Post.findOne({where: {published: false}, order: 'date DESC'}, function (err, dat
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
User.create({name: 'Jeff'}, function (err, data) {
|
User.create({name: 'Jeff', age: 12}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return;
|
return;
|
||||||
|
@ -78,7 +78,7 @@ User.create({name: 'Ray'}, function (err, data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
User.scope('minors', {age: {le: 16}});
|
User.scope('minors', {where: {age: {lte: 16}}, include: 'posts'});
|
||||||
User.minors(function (err, kids) {
|
User.minors(function (err, kids) {
|
||||||
console.log('Kids: ', kids);
|
console.log('Kids: ', kids);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue