Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created October 28, 2011 20:04
Show Gist options
  • Save boxxxie/1323405 to your computer and use it in GitHub Desktop.
Save boxxxie/1323405 to your computer and use it in GitHub Desktop.
var Campaign = Backbone.Model.extend(
{
idAttribute: "_id",
urlRoot:"http://localhost:5984/campaigns"
});
var Campaigns = Backbone.Collection.extend(
{
model: Campaign,
url:"http://localhost:5984/campaigns/_all_docs",
parse: function(response) {
return _(response.rows).chain()
.pluck('id')
.reject(function(id){return id.search('_design') == 0;})
.map(function(id){return{_id:id};})
.value();
}
});
var campaignList = new Campaigns();
campaignList.fetch(
{success:function(model,resp){
console.log("model");
console.log(model);
console.log("resp");
console.log(resp);
_.each(model,function(model)
{
model.fetch({success:console.log});
});
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment