Question

I'm trying to pass data from Appcelerator Cloud Services to Backbone models. I couldn't find documentation on how to do this...

Below is the config from my model file:

exports.definition = {
    config: {
        "columns": {
            "id":"integer",
            "address":"text",
            "user_completed":"integer"
        },
        "adapter": {
            "type": "", //what can I enter?
            "collection_name": "places"
        }
    },
    extendModel : function(Model) {
        _.extend(Model.prototype, {
            validate : function(attrs) {
                for (var key in attrs) {
                    var value = attrs[key];
                    if (value) {
                        if (key === "item") {
                            if (value.length <= 0) {
                                return 'Error: No item!';
                            }
                        }
                        if (key === "done") {
                            if (value.length <= 0) {
                                return 'Error: No completed flag!';
                            }
                        }
                    }
                }
            }
        });

        return Model;
    },

    extendCollection : function(Collection) {
        _.extend(Collection.prototype, {
            comparator: function(places) {
                return places.get('done');
            }
        });

        return Collection;
    }
};

How can I pass data from ACS?

Was it helpful?

Solution

You need to use "acs" in your config.

Check this :

exports.definition = {
config: {
    "columns": {
        "id":"integer",
        "address":"text",
        "user_completed":"integer"
    },
    "adapter": {
        "type": "acs",  // Use "acs"
        "collection_name": "places"
    }
},
extendModel : function(Model) {
    _.extend(Model.prototype, {
        validate : function(attrs) {
            for (var key in attrs) {
                var value = attrs[key];
                if (value) {
                    if (key === "item") {
                        if (value.length <= 0) {
                            return 'Error: No item!';
                        }
                    }
                    if (key === "done") {
                        if (value.length <= 0) {
                            return 'Error: No completed flag!';
                        }
                    }
                }
            }
        }
    });

    return Model;
},

extendCollection : function(Collection) {
    _.extend(Collection.prototype, {
        comparator: function(places) {
            return places.get('done');
        }
    });

    return Collection;
}
};

Check this presentation : Titanium presentation under ACS topic with "ACS in Alloy" header.

Also , here is sample example : Alloy backbone & ACS

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top