[ALOY-137] All "model" config and code should be contained in a single file
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Resolved |
Resolution | Fixed |
Resolution Date | 2012-09-19T23:27:42.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2012 Sprint 19, Release 3.0.0 |
Components | Runtime, XML |
Labels | n/a |
Reporter | Tony Lukasavage |
Assignee | Russell McMahon |
Created | 2012-07-26T12:16:56.000+0000 |
Updated | 2013-05-01T14:56:12.000+0000 |
Description
problem
I'd like to make the models actual JS and have them export configurations, as well as custom scripts. Right now having amodel.json
with the model config and then an optional extra model.js
for a custom script feels a bit grafted together, and it's just more for a developer to need to keep track of. I'd rather have a single model.js
file with all this information. And since we have the (model) generators at our disposal, I don't think this will be overwhelming for a developer to understand or use.
proposed solution
This is by no means final, but a generated model should probably look more like the below sample. Notes: * "name" and "config" would come fromalloy generate model
* migrations would be added at compile time, if necessary
var Alloy = require('alloy');
var name = "nameFromGenerate";
var config = {
"columns": {
"count": "Int"
},
"defaults": {
"count": 0
},
"adapter": {
"type": "properties",
"prefix": "app"
}
};
var Model = Alloy.M(name, config);
///////////////////////////////////////////////////////
///// INSERT CODE HERE TO EXTEND MODEL DEFINITION /////
///////////////////////////////////////////////////////
var Collection = Alloy.Backbone.Collection.extend({model:Model});
Collection.prototype.config = Model.prototype.config;
exports.Model = Model;
exports.Collection = Collection;
Comments
- Tony Lukasavage 2012-09-11 This should be resolved by ALOY-193. Update this ticket if it is not.