What column types are supported by model?
Closed this issue · 3 comments
Hi,
Does the model just use javascript types?
Also, how do I create association between different models?
Alloy has built-in Backbone support. Backbone models are key/value pairs, for example {name: "myName", height: "myHeight"} so yes JSON/Javascript syntax. We have not yet done testing with multiple models but you should be able to describe multiple models and access the models directly, but you will need to relate them yourself. Alloy current does not have built in support for relating models but it is something we are looking into.
Thanks for the reply! I have another question related to view. I'll open a separate issue.
The supported types in model definitions are determined by the type of adapter you choose. For example, if you look at the simple model in the properties_model example, its adapter type is set to properties. This adapter refers to Titanium's native Ti.App.Properties API that does local persistence of data, and works on all supported platforms (iOS, Android, and Mobileweb).
{
"columns": {
"count": "Int"
},
"defaults": {
"count": 0
},
"adapter": {
"type": "properties",
"prefix": "singleModel"
}
}
The actual types listed, like Int in this example, refer to the types supported by the Ti.App.Properties API, whose full documentation can be found here: http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Titanium.App.Properties
If you instead used a sql adapter type, your field types would refer to the types supported by SQLite. Same goes for any other adapter.