How to use the comb.Promise function in comb

To help you get started, we’ve selected a few comb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github C2FO / patio / example / querying.example.js View on Github external
return DB.transaction(function () {
        var ret = new comb.Promise();
        User.forUpdate().first({id: 1}).chain(function (user) {
            // SELECT * FROM user WHERE id = 1 FOR UPDATE
            user.password = null;
            user.save().chain(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
        }, comb.hitch(ret, "errback"));
        return ret;
    });
};
github C2FO / patio / test / data / timestampPlugin / timestamp.default.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables();
        var Employee = patio.addModel(DB.from("employee"), {
            plugins:[patio.plugins.TimeStampPlugin]
        });
        Employee.timestamp();
        patio.syncModels();
    });
};
github C2FO / patio / test / data / oneToOne / eager.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables();
        var Works = patio.addModel(DB.from("works"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.manyToOne("employee", {fetchType:this.fetchType.EAGER});
                }
            }
        });
        var Employee = patio.addModel(DB.from("employee"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.oneToOne("works", {fetchType:this.fetchType.EAGER});
                }
github adlnet / lrs-conformance-test-suite / test / helper.js View on Github external
var delay = function(val)
            {
                var p = new comb.Promise();
                var endP = module.exports.getEndpointStatements();
                if (query) {
                    endP += query;
                }
                var delta, finish;

                function doRequest()
                {
                    if(global.OAUTH)
                        request = module.exports.OAuthRequest(request);
                    var result;
                    request(module.exports.getEndpointAndAuth())
                    .get(endP)
                    .headers(module.exports.addAllHeaders({}))
                    //we don't expect anything, we just want a response
                    .end(function(err, res)
github C2FO / patio / test / data / manyToMany / lazy.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables();
        var Company = patio.addModel(DB.from("company"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.manyToMany("employees");
                }
            }
        });
        var Employee = patio.addModel(DB.from("employee"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.manyToMany("companies");
                }
github C2FO / patio / test / data / ctiPlugin / classTableInheritance.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    helper.createTables(true).then(function () {
        var Employee = patio.addModel("employee", {
            plugins:[ClassTableInheritance],
            static:{

                init:function () {
                    this._super(arguments);
                    this.configure({key:"kind"});
                }
            }
        });
        var Staff = patio.addModel("staff", Employee, {

            static:{

                init:function () {
github C2FO / patio / test / data / manyToMany / camelize.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables(true);
        var Company = patio.addModel(DB.from("company"), {
            static:{

                identifierOutputMethod:"camelize",

                identifierInputMethod:"underscore",

                init:function () {
                    this._super(arguments);
                    this.manyToMany("employees");
                }
            }
        });
        var Employee = patio.addModel(DB.from("employee"), {
github C2FO / patio / test / helpers / helper.js View on Github external
execute: function (sql, opts) {
            var ret = new comb.Promise();
            this.sqls.push(sql);
            ret.callback();
            return ret;
        }
    }
github C2FO / patio / test / data / timestampPlugin / timestamp.customColumns.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables(true);
        var Employee = patio.addModel(DB.from("employee"), {
            plugins:[patio.plugins.TimeStampPlugin]
        });
        Employee.timestamp({updated : "updatedAt", created : "createdAt"});
        return patio.syncModels();
    });
};
github C2FO / patio / example / migration / timestampMigration.example.js View on Github external
var checkTables = function () {
    var ret = new comb.Promise();
    comb.when(DB.tableExists("class"), DB.tableExists("student"), DB.tableExists("classesStudents"), DB.from("schema_migrations").selectMap("filename"), function (res) {
        console.log("The class table %s exist!", res[0] ? "does" : "does not");
        console.log("The student table %s exist!", res[1] ? "does" : "does not");
        console.log("the classes_students table %s exist!", res[2] ? "does" : "does not");
        if (res[3].length) {
            console.log("The following migrations are currently applied : \n\t%s ", res[3].join("\n\t"));
        } else {
            console.log("No migrations are currently applied");
        }
        ret.callback();
    }, comb.hitch(ret, "errback"));
    return ret;
}