Quantcast
Viewing all articles
Browse latest Browse all 8068

Cannot Save Model

Hi,

I have two collections and two models, One of them cannot save, what is the problem?

drugpool Model

var moment = require('alloy/moment');
 
exports.definition = {
    config: {
        "columns": {
            "title":"text",
            "done":"integer"
        },
        "adapter": {
            "type": "sql",
            "collection_name": "drugpool"
        }
    },
    extendModel: function(Model) {
        _.extend(Model.prototype, {
            validate : function(attrs) {
                for (var key in attrs) {
                    var value = attrs[key];
                    if (value) {
 
                    }
                }
            }
        });
 
        return Model;
    },
    extendCollection: function(Collection) {
        _.extend(Collection.prototype, {
            comparator: function(todo) {
                return drugpool.get('done');
            }
        });
 
        return Collection;
    }
};
main.js
var book = Alloy.createModel('drugpool', {title:'Green Eggs and Ham', done:0}); 
    if (book.isValid()) {
        book.save();
    }

Viewing all articles
Browse latest Browse all 8068

Trending Articles