Reputation: 79
I'm learning how to code & I'm trying to understand the following code from an app built w/ the Titanium Alloy MVC framework.
The below code is from the model
file called class
. I've done research on the Alloy MVC framework, 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, {
urlRoot: '/school/',
name:'school',
parse: function(response, options) {
response.id = response._id;
return response;
},
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {
urlRoot: '/schools/',
name: 'schools',
});
return Collection;
}
}
Upvotes: 0
Views: 244
Reputation: 33345
I suggest that you contact the person who wrote the sync adapter that you are using since the functionality described in the code sample is not part of the base Alloy Framework.
I would also take a look at some backbonejs documentation on Models and collections to understand that functionality.
finally without providing the source code or reference to the sync adapter, it will be really difficult to provide additional information.
Upvotes: 1