Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxnowack/meteor-querychain
This package enables chaining mongo cursors for Meteor
https://github.com/maxnowack/meteor-querychain
Last synced: 4 days ago
JSON representation
This package enables chaining mongo cursors for Meteor
- Host: GitHub
- URL: https://github.com/maxnowack/meteor-querychain
- Owner: maxnowack
- License: mit
- Created: 2015-02-11T20:08:55.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-13T21:41:56.000Z (over 9 years ago)
- Last Synced: 2024-11-01T18:42:45.242Z (11 days ago)
- Language: CoffeeScript
- Size: 152 KB
- Stars: 21
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QueryChain
This package enables chaining mongo cursors like this:
````javascript
Posts.find().fromMax().withComments()
````## Installation
````
meteor add maxnowack:querychain
````## Usage
````javascript
Posts = new Mongo.Collection('posts');// add a chain method
QueryChain.add({
withComments: { // name of the method
query: { // a mongo query
comments: {
$gt: 0
}
}
}
});// it's also possible, to define a function to provide a query
QueryChain.add({
from: {
query: function(name){
return {
author: name
}
}
}
});Posts.find().withComments() // returns a cursor for the query speficied above
// you can also chain multiple methods:
QueryChain.add({
fromMax: {
query: {
author: 'Max'
}
}
});Posts.find().fromMax().withComments()
// or limit methods to specific collections
QueryChain.add({
notFromMax: {
collection: Posts
query: {
author: {
$ne: 'Max'
}
}
}
});
````