Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Problems with backbone and auto-increment

$
0
0

All,

I'm having an issue with my auto-increment ID on a model. This is my model def:

exports.definition = {
    config: {
        columns: {
            "id": "INTEGER PRIMARY KEY AUTOINCREMENT",
            "name": "TEXT",
            "url": "TEXT"
        },
        "defaults": {
            "name": "",
            "url": "",
            "id": -1
        },
        adapter: {
            type: "sql",
            collection_name: "ServerSettings",
            idAttribute:'id'
        }
    },
    extendModel: function(Model) {
        _.extend(Model.prototype, {
            // extended functions and properties go here
        });
 
        return Model;
    },
    extendCollection: function(Collection) {
        _.extend(Collection.prototype, {
            // extended functions and properties go here
        });
 
        return Collection;
    }
};
I'm creating it with the following code:
var entity = Alloy.createModel('ServerSettings', {name: name, url: url});
settings.add(entity);
 
entity.save();
The 'settings' collection is previous created using:
var settings = Alloy.Collections.ServerSettings;
settings.fetch();
The issue is that the 'id' continues to come out as '-1'. It is not being auto-incremented.

Not sure why this wouldn't work.

Any thoughts would be welcome.

Thanks!

-C-


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>