Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var patio = require("../../index"), comb = require("comb"), format = comb.string.format, assert = require("assert");
patio.camelize = true;
var DB = patio.createConnection("mysql://test:testpass@localhost:3306/sandbox");
new comb.logging.BasicConfigurator().configure();
comb.logging.Logger.getRootLogger().level = "info";
var disconnectErr = function (err) {
patio.logError(err);
patio.disconnect();
};
var checkTables = function () {
return DB.from("employees")
.forEach(function (employee) {
console.log(format("{id} {firstName} {middleInitial} {lastName} was hired {[yyy-MM-dd]hireDate}", employee));
return employee;
})
.chain(function (employees) {
assert.equal(employees.length, 5);
});
}
var patio = require("../../index"), comb = require("comb"), format = comb.string.format, assert = require("assert");
patio.camelize = true;
var DB = patio.createConnection("mysql://test:testpass@localhost:3306/sandbox");
new comb.logging.BasicConfigurator().configure();
comb.logging.Logger.getRootLogger().level = "info";
var disconnectErr = function (err) {
patio.logError(err);
patio.disconnect();
};
var checkTables = function () {
return DB.from("employees")
.forEach(function (employee) {
console.log(format("{id} {firstName} {middleInitial} {lastName} was hired {[yyy-MM-dd]hireDate}", employee));
return employee;
})
.chain(function (employees) {
assert.equal(employees.length, 5);
});
}
var comb = require("comb"),
Promise = comb.Promise,
PromiseList = comb.PromiseList,
Hive = require("hive-cache");
var hive;
var i = 0;
var LOGGER = comb.logging.Logger.getLogger("patio.plugins.CachePlugin");
/**
* @class Adds in memory caching support for models.
*
* @example
*
* var MyModel = patio.addModel("testTable", {
* plugins : [patio.plugins.CachePlugin];
* });
*
* //NOW IT WILL CACHE
*
* @name CachePlugin
* @memberOf patio.plugins
*/
exports.CachePlugin = comb.define(null, {
instance: {
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,
when = comb.when,
logging = comb.logging,
Logger = logging.Logger,
Promise = comb.Promise,
PromiseList = comb.PromiseList,
TransformStream = require("stream").Transform,
pipeAll = require("../utils").pipeAll;
var Dataset;
var LOGGER = Logger.getLogger("patio.Dataset");
function partition(arr, sliceSize) {
var output = [], j = 0;
for (var i = 0, l = arr.length; i < l; i += sliceSize) {
output[j++] = arr.slice(i, i + sliceSize);
}
return output;
var comb = require("comb"),
logging = comb.logging,
Logger = logging.Logger,
errors = require("../errors"),
QueryError = errors.QueryError,
DatasetError = errors.DatasetError,
Promise = comb.Promise,
PromiseList = comb.PromiseList,
isUndefined = comb.isUndefined,
isUndefinedOrNull = comb.isUndefinedOrNull,
isString = comb.isString,
isInstanceOf = comb.isInstanceOf,
isString = comb.isString,
isFunction = comb.isFunction,
isNull = comb.isNull,
merge = comb.merge,
define = comb.define,
graph = require("./graph"),
var comb = require("comb"),
define = comb.define,
Promise = comb.Promise,
spreadArgs = comb.__spreadArgs,
isFunction = comb.isFunction,
logging = comb.logging,
Logger = logging.Logger,
format = comb.string.format,
QueryError = require("../errors").QueryError;
var LOGGER = Logger.getLogger("patio.Database");
define(null, {
instance: {
/**@lends patio.Database.prototype*/
/**
* Logs an INFO level message to the "patio.Database" logger.
*/
logInfo: function () {
LOGGER.info.apply(LOGGER, arguments);
"use strict";
var patio = require("../index"),
sql = patio.sql,
comb = require("comb"),
format = comb.string.format;
patio.camelize = true;
patio.configureLogging();
patio.LOGGER.level = comb.logging.Level.ERROR;
var DB = patio.connect("mysql://test:testpass@localhost:3306/sandbox");
var User = patio.addModel("user");
var Blog = patio.addModel("blog");
//disconnect and error callback helpers
var disconnect = function () {
DB.forceDropTable("blog", "user").both(comb.hitch(patio, "disconnect"));
};
var disconnectError = function (err) {
patio.logError(err);
DB.forceDropTable("blog", "user").both(comb.hitch(patio, "disconnect"));
};
var connectAndCreateSchema = function () {