Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
if (children.length) {
console.log("The children's names are " + children.map(function (child) {
return child.name;
}));
}
});
});
})
.chain(function () {
return Child.findById(1).chain(function (child) {
return child.biologicalFather.chain(function (father) {
console.log(child.name + " father is " + father.name);
});
});
})
.chain(comb.hitch(patio, "disconnect"), errorHandler);
this.isVerified(Boolean, {"default": false});
this.lastAccessed(Date);
this.created(sql.TimeStamp);
this.updated(sql.DateTime);
});
},
function () {
return DB.createTable("blog", function () {
this.primaryKey("id");
this.title(String);
this.numPosts("integer");
this.numFollowers("integer");
this.foreignKey("userId", "user", {key: "id"});
});
},
comb.hitch(patio, "syncModels")
]);
};
//GPA
this.gpa(sql.Decimal, {size: [1, 3], "default": 0.0});
//Honors Program?
this.isHonors(Boolean, {"default": false});
//freshman, sophmore, junior, or senior
this.classYear("char");
})
);
},
function () {
return DB.createTable("students_classes", function () {
this.foreignKey("studentId", "student", {key: "id"});
this.foreignKey("classId", "class", {key: "id"});
});
},
comb.hitch(patio, "syncModels")
]);
};
//GPA
this.gpa(sql.Decimal, {size: [1, 3], "default": 0.0});
//Honors Program?
this.isHonors(Boolean, {"default": false});
//freshman, sophmore, junior, or senior
this.classYear("char");
})
);
},
function () {
return DB.createTable("classes_students", function () {
this.foreignKey("studentId", "student", {key: "id"});
this.foreignKey("classId", "class", {key: "id"});
});
},
comb.hitch(patio, "syncModels")
]);
};
routes: function () {
if (comb.isUndefined(this.__routes)) {
var routes = this.__routes = [
["get", "/" + this.tableName + "/:id", comb.hitch(this, "findByIdRoute")],
["delete", "/" + this.tableName + "/:id", comb.hitch(this, "removeByIdRoute")]
];
}
return this.__routes;
}
//GPA
this.gpa(sql.Decimal, {size: [1, 3], "default": 0.0});
//Honors Program?
this.isHonors(Boolean, {"default": false});
//freshman, sophmore, junior, or senior
this.classYear("char");
})
);
},
function () {
return DB.createTable("classes_students", function () {
this.foreignKey("studentKey", "student", {key: "id"});
this.foreignKey("classKey", "class", {key: "id"});
});
},
comb.hitch(patio, "syncModels")
]);
};
DB.createTable("stepFather", function () {
this.primaryKey("id");
this.name(String, {unique: true});
})
);
},
function () {
return DB.createTable("child", function () {
this.primaryKey("id");
this.name(String);
this.foreignKey("biologicalFatherId", "biologicalFather", {key: "id"});
this.foreignKey("stepFatherId", "stepFather", {key: "name", type: String});
});
},
comb.hitch(patio, "syncModels")
]);
};
this.classYear("char");
})
);
},
function () {
//this isnt very practical but it gets the point across
return DB.createTable("classes_students", function () {
this.firstNameKey(String);
this.lastNameKey(String);
this.nameKey(String);
this.subjectKey(String);
this.foreignKey(["firstNameKey", "lastNameKey"], "student", {key: ["firstName", "lastName"]});
this.foreignKey(["nameKey", "subjectKey"], "class", {key: ["name", "subject"]});
});
},
comb.hitch(patio, "syncModels")
]);
};