Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
};
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();
});
};
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});
}
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)
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");
}
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 () {
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"), {
execute: function (sql, opts) {
var ret = new comb.Promise();
this.sqls.push(sql);
ret.callback();
return ret;
}
}
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();
});
};
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;
}