Skip to content

Simple library to build urls for querying REST resources defined by settings.

License

Notifications You must be signed in to change notification settings

jthoms1/backbone.querybuilder

Repository files navigation

Build Status

backbone.querybuilder

Simple library that helps manage api interactions with web services.

Usage

/*
 * Create model, define expected sub models/collections that will be included.
 * Passing reference to the submodels collections always backbone.includes to choose
 * whether a model or collection should be used based on whether the attribute is a
 * collection or an object.
 */
var user = new User();
user.limit(10).fetch();
// Fetch User model and include related role and organization
var user = new User({'id': 1});
user.includeRelated('role', 'organization').fetch();
// Fetch User models when user's role is editor or author
var users = new UserCollection();
users.when({
    role: ['editor', 'author']
}).fetch();
// Fetch 10 User models that are on the 
var users = new UserCollection();
users.limit(10).skip(2).fetch();
var users = new UserCollection();
users.orderBy('lastName').fetch();

About

Simple library to build urls for querying REST resources defined by settings.

Resources

License

Stars

Watchers

Forks

Packages

No packages published