Skip to content

Commit

Permalink
Add Query
Browse files Browse the repository at this point in the history
  • Loading branch information
biggora committed May 9, 2013
1 parent f89834e commit 97a80f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Count instances

```javascript
// count posts by user
User.count({where: {userId: user.id}}, function(err, count){
Post.count({where: {userId: user.id}}, function(err, count){
// your code here
});
```
Expand Down
21 changes: 12 additions & 9 deletions tests/new_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,26 @@ var Product = schema.define('product', {
type: Number
}
});

/*
*/
var Query1 = Product.find();
Query1.skip(10);
Query1.limit(10);
Query1.asc('id');
Query1.run(function(err, inst){
Query1.all(function(err, inst){
// console.log(err, inst);
console.log('Query1');
});

Product.findOne({order:"id ASC"},function(err, inst){
// console.log(err, inst);
console.log('Query3', inst.id);
});

var Query2 = Product.find();
Query2.where('id').gt(100).lt(200);
Query2.skip(10);
Query2.limit(10);
Query2.asc('id');
Query2.run(function(err, inst){
console.log(err, inst);
/**/
Product.find().where('id').gt(100).lt(150).limit(10).asc('id').run(function(err, inst){
// console.log(err, inst);
console.log('Query2');
});


Expand Down

0 comments on commit 97a80f5

Please sign in to comment.