[ALOY-467] idAttribute assignable from Model config
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-08-06T06:24:55.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 0.3.5, 2013 Sprint 02 |
Components | Runtime |
Labels | qe-Alloy, qe-manualtest |
Reporter | Tony Lukasavage |
Assignee | Tony Lukasavage |
Created | 2013-01-16T11:37:54.000+0000 |
Updated | 2014-08-06T06:24:55.000+0000 |
Description
The Backbone idAttribute property, which determines which backend property is the unique identifier for a Backbone model, should be assignable through the model.js config.definition object. That way Alloy can automatically apply that idAttribute to all created models. It will also signal Alloy to *_not_* create an additional "id" field like it does now for uniquely identifying records. Alloy should only create an additional id row if absolutely necessary and this will allow the developers to prevent that.
sample
This sample will tell Alloy (and Backbone) to use *myId* as the idAttribute for all models created from this definition. It will additionally tell Alloy to *_not_* create an additional id field for uniquely identifying records. If we were to remove the *idAttribute* property, then Alloy would in fact create an id column.
exports.definition = {
config: {
"columns": {
"name":"TEXT",
"nickname":"TEXT",
"myId": "INTEGER PRIMARY KEY AUTOINCREMENT"
},
"adapter": {
"type": "sql",
"collection_name": "fighters",
},
"idAttribute": "myId"
}
}
Present in this test app: https://github.com/appcelerator/alloy/tree/master/test/apps/models/sql_keywords
Verified fixed also on 1_0_X master branch android device: 4.2 iPhone devices: iPhone 6 and iPad 4.3.5 TiSDK: 3.0.2.v20130124164131 CLI: 3.0.23 Closing.
Reopening for adding labels