I Have the following Backbone Collection Code :
AssessmentSlos = Backbone.Collection.extend({
url: "mapping",
db: {
view: "slosByAssessmentId"
},
fetch: function(options) {
options = {};
options.data ={};
options.data.date = "2013-10";
return Backbone.Collection.prototype.fetch.call(this, options);
}
});
THe Code For initializing and calling fetch is this
c = new AssessmentSlos();
c.fetch();
Expected/Correct URL Request Should Be like this one
http://localhost:5984/tangerine/_design/tangerine/_view/slosByAssessmentId?date=2011-10
But When i inspect i get this:
http://localhost:5984/tangerine/_design/tangerine/_view/slosByAssessmentId?cacheBuster=126
Why My Date Query is not showing in the url query ? I followed this simple guide http://japhr.blogspot.in/2011/10/overriding-url-and-fetch-in-backbonejs.html
According to the guide this code should be working. What is my mistake ?
The issue is not with backbone, it's the backbone-couchdb connector which was changing my fetch parameters,So to achieve it I added query's to the "db" object of collection class, e.g fetching on keys will be like this
AssessmentSlos = Backbone.Collection.extend({
url: "mapping",
db: {
view: "slosByAssessmentId"
,keys: ["2013-10"]
},
fetch: function(options) {
options = {};
options.data ={};
options.data.date = "2013-10";
return Backbone.Collection.prototype.fetch.call(this, options);
}
});