backbone_query - MongoDB-like query interface to Backbone collections
Nice JavaScript add-on for Backbone from Dave Tonge that provides a MongoDB-like query API for your collections:
MyCollection.query({
// Models must match all these queries
$and:{
title: {$like: "news"}, // Title attribute contains the string "news"
likes: {$gt: 10}}, // Likes attribute is greater than 10
// Models must match one of these queries
$or:{
featured: true, // Featured attribute is true
category:{$in:["code","programming","javascript"]}}
//Category attribute is either "code", "programming", or "javascript"
});
Check the README for usage.
Discussion
Sign in or Join to comment or subscribe