Created
October 28, 2011 20:40
-
-
Save boxxxie/1323487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
>>> campaignList.at(0).fetch() | |
GET http://localhost:5984/campaigns/_all_docs/AllCanadaAllTerminal | |
I want this to happen | |
GET http://localhost:5984/campaigns/AllCanadaAllTerminal | |
*/ | |
var Campaign = Backbone.Model.extend( | |
{ | |
idAttribute: "_id", | |
url:"http://localhost:5984/campaigns/" + this._id | |
}); | |
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 new Campaign({_id:id});}) | |
.value(); | |
} | |
}); | |
campaignList = new Campaigns(); | |
campaignList.fetch( | |
{ include_docs:true, | |
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