Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var comb = require("comb"),
asyncArray = comb.async.array,
isFunction = comb.isFunction,
isUndefined = comb.isUndefined,
isDefined = comb.isDefined,
isBoolean = comb.isBoolean,
isString = comb.isString,
argsToArray = comb.argsToArray,
isInstanceOf = comb.isInstanceOf,
isHash = comb.isHash,
when = comb.when,
merge = comb.merge,
toArray = comb.array.toArray,
ModelError = require("./errors").ModelError,
plugins = require("./plugins"),
isUndefinedOrNull = comb.isUndefinedOrNull,
AssociationPlugin = plugins.AssociationPlugin,
QueryPlugin = plugins.QueryPlugin,
var mysql = require("mysql"),
comb = require("comb"),
hitch = comb.hitch,
asyncArray = comb.async.array,
define = comb.define,
merge = comb.merge,
string = comb.string,
argsToArray = comb.argsToArray,
format = string.format,
Promise = comb.Promise,
isString = comb.isString,
array = comb.array,
toArray = array.toArray,
isArray = comb.isArray,
isHash = comb.isHash,
when = comb.when,
isInstanceOf = comb.isInstanceOf,
isFunction = comb.isFunction,
isUndefinedOrNull = comb.isUndefinedOrNull,
isUndefined = comb.isUndefined,
_parseExpect: function (res, body, promise) {
var headers = res.headers;
comb.async.array(this._expects).forEach(function (expect) {
switch (expect[0]) {
case "cookie":
//testing for cookies
var key = expect[1], val = expect[2], cookie = getCookie(key, this._jar, this._baseUrl);
if (comb.isUndefined(cookie)) {
throw new Error("expected cookie " + key + " to be present");
}
if (val) {
if (comb.isHash(val) && !comb.deepEqual(cookie, val)) {
throw new Error("expected cookie " + key + " to equal " + JSON.stringify(val) + "\n" + expect[3]);
} else if (cookie.value === val) {
throw new Error("expected cookie " + key + " value to equal " + val);
}
}
break;
case "!cookie":
var associations = require("../associations"),
oneToMany = associations.oneToMany,
manyToOne = associations.manyToOne,
oneToOne = associations.oneToOne,
manyToMany = associations.manyToMany,
fetch = associations.fetch,
comb = require("comb"),
asyncArray = comb.async.array,
Promise = comb.Promise,
PromiseList = comb.PromiseList;
var RECIPROCAL_ASSOC = {
"oneToOne": ["manyToOne"],
"manyToOne": ["oneToMany", "oneToOne"],
"oneToMany": ["manyToOne"],
"manyToMany": ["manyToMany"]
};
exports.AssociationPlugin = comb.define(null, {
instance: {
/**@lends patio.Model.prototype*/
function exec(cmds) {
if (!comb.isArray(cmds)) {
cmds = [cmds];
}
return comb.async.array(cmds).forEach(function (cmd) {
if (cmd) {
log.debug(util.format("Executing %s %s", cmd.cmd, cmd.args.join(" ")));
var child = execP(cmd.cmd, cmd.args, { stdio: "inherit" }),
ret = new comb.Promise();
child.on("close", function (code) {
if (code !== 0) {
ret.errback(new Error("ps process exited with code " + code));
} else {
ret.callback();
}
});
child.on("error", ret.errback);
return ret;
}
}, 1);
return comb.when(classDs.all(), studentDs.all()).chain(function (results) {
//enroll the students
var classes = results[0], students = results[1];
return comb.async.array(students)
.map(function (student, i) {
if (i === 0) {
return student.enroll(classes);
} else if (i < classes.length) {
return student.enroll(classes.slice(i));
}
})
.chain(function () {
return Student.save({
firstName: "Zach",
lastName: "Igor",
gpa: 2.754,
classYear: "Sophmore",
classes: [
{
semester: "FALL",
var comb = require("comb"),
errors = require("../errors"),
asyncArray = comb.async.array,
NotImplemented = errors.NotImplemented,
QueryError = errors.QueryError,
sql = require("../sql").sql,
Identifier = sql.Identifier,
isUndefinedOrNull = comb.isUndefinedOrNull,
argsToArray = comb.argsToArray,
isFunction = comb.isFunction,
isNumber = comb.isNumber,
QualifiedIdentifier = sql.QualifiedIdentifier,
AliasedExpression = sql.AliasedExpression,
define = comb.define,
isInstanceOf = comb.isInstanceOf,
merge = comb.merge,
isBoolean = comb.isBoolean,
isString = comb.isString,
flatten = comb.array.flatten,
return comb.when(classDs.all(), studentDs.all()).chain(function (results) {
//enroll the students
var classes = results[0], students = results[1];
return comb.async.array(students).map(function (student, i) {
if (i === 0) {
return student.enroll(classes);
} else if (i < classes.length) {
return student.enroll(classes.slice(i));
}
})
.chain(function () {
return Student.save({
firstName: "Zach",
lastName: "Igor",
gpa: 2.754,
classYear: "Sophmore",
classes: [
{
semester: "FALL",
name: "Compiler Construction 2",
return comb.when(classDs.all(), studentDs.all()).chain(function (results) {
//enroll the students
var classes = results[0], students = results[1];
return comb.async.array(students)
.map(function (student, i) {
if (i === 0) {
return student.enroll(classes);
} else if (i < classes.length) {
return student.enroll(classes.slice(i));
}
})
.chain(function () {
return Student.save({
firstName: "Zach",
lastName: "Igor",
gpa: 2.754,
classYear: "Sophmore",
classes: [
{
semester: "FALL",
var comb = require("comb"),
asyncArray = comb.async,
Promise = comb.Promise,
PromiseList = comb.PromiseList;
comb.define(null, {
instance: {},
"static": {
configure: function (model) {
}
}
}).as(exports, "SingleTableInheritance");
/**
* @class This plugin enables