I'm a learning coder trying to understand this code from a sample MVC framework.
The below code is from a "model" file. I've done research on Backbone.js, but I'm still confused as to exactly how this code pull information from the app's database. For example, how are base_url, Model.prototype, and Collection.prototype being used to retrieve information from the backend? Any help would be greatly appreciated.
exports.definition = {
config : {
"defaults": {
"title": "-",
"description": "-"
},
"adapter": {
"type": "rest",
"collection_name": "schools",
"base_url" : "/schools/",
}
},
extendModel: function(Model) {
_.extend(Model.prototype, {
// Extend, override or implement Backbone.Model
urlRoot: '/school/',
name:'school',
parse: function(response, options) {
response.id = response._id;
return response;
},
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {
// Extend, override or implement Backbone.Collection
urlRoot: '/schools/',
name: 'schools',
});
return Collection;
}
}