0
我正在學習如何編寫代碼&我想了解從鈦合金MVC框架構建的應用程序中的以下代碼。鈦合金MVC框架 - 「型號」查詢
以下代碼來自model
文件,名爲class
。我已經對Alloy MVC框架進行了研究,但我仍然對這個代碼如何從應用程序的數據庫中獲取信息感到困惑。例如,如何使用base_url
,Model.prototype
和Collection.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;
}
}