0

我正在学习如何编码,我正在尝试从使用 Titanium Alloy MVC 框架构建的应用程序中理解以下代码。

下面的代码来自model名为class. 我已经对 Alloy MVC 框架进行了研究,但我仍然对这段代码如何从应用程序的数据库中提取信息感到困惑。例如,如何使用base_urlModel.prototypeCollection.prototype来从后端检索信息?任何帮助将不胜感激。

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;
 }
}
4

1 回答 1

1

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.

于 2013-06-27T00:57:14.333 回答