_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q54600 | insertInTrie | train | function insertInTrie({ parts, isIcann }, trie) {
let node = trie;
for (let i = 0; i < parts.length; i += 1) {
const part = parts[i];
let nextNode = node[part];
if (nextNode === undefined) {
nextNode = {};
node[part] = nextNode;
}
node = nextNode;
}
node.$ = isIcann ? 1 : 2;
return trie;
} | javascript | {
"resource": ""
} |
q54601 | getXPosAdjustedForKink | train | function getXPosAdjustedForKink(pos) {
var first = clinicalTimelineUtil.getLowerBoundIndex(ticksToShow, pos);
var second = first + 1;
if (second > ticksToShow.length - 1) {
return tickCoordinatesKink[first];
}
return tickCoordinatesKink[first] + (pos - ticksToShow[first]) * (tickCoordinatesKink[second] - tickCoordinatesKink[first]) / (ticksToShow[second] - ticksToShow[first]);
} | javascript | {
"resource": ""
} |
q54602 | clickHandlerKink | train | function clickHandlerKink() {
timeline.pluginSetOrGetState("trimClinicalTimeline", false);
//create a bounding box to ease the clicking of axis
xAxisBBox = d3.select(timeline.divId()+" > svg > g > g.axis")[0][0].getBBox()
d3.select(timeline.divId()+"> svg > g")
.insert("rect")
.attr("x", xAxisBBox.x)
.attr("y", 4)
.attr("width", xAxisBBox.width)
.attr("height", xAxisBBox.height)
.attr("fill", "rgba(0,0,0,0)")
.style("cursor", "pointer")
.on("click", function () {
timeline.pluginSetOrGetState("trimClinicalTimeline", true);
})
.append("svg:title")
.text("Click to trim the timeline");
} | javascript | {
"resource": ""
} |
q54603 | lookup | train | function lookup(latitude, longitude, countryCode) {
let minDistance = Infinity
let city = {}
// start with inout values
const start = { latitude, longitude }
// iterate through all locations
try {
const otherCountryOrigin = require(`../locations/${countryCode}.json`)
otherCountryOrigin.forEach((location) => {
const distance = haversine.distance(start, location)
if (distance < minDistance) {
city = location
minDistance = distance
}
})
} catch (e) {
return undefined
}
// add distance to city object
city.distance = minDistance
// return city object
return city
} | javascript | {
"resource": ""
} |
q54604 | train | function () {
$("#addtrack").css("visibility","hidden");
var element = document.getElementsByTagName('path')[0];
element.setAttribute("stroke" , "black");
element.setAttribute("fill" , "none");
element = document.getElementsByTagName('line');
for( var i=0 ; i<element.length ; i++)
{
element[i].setAttribute("stroke" , "black");
element[i].setAttribute("fill" , "none");
}
var svg = document.querySelector(spec.timelineDiv+" svg");
var serializer = new XMLSerializer();
var source = serializer.serializeToString(svg);
var link = document.createElement("a");
//name spaces
if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
}
if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
}
//xml declaration
source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
//converting SVG source to URI data scheme.
var url = "data:image/svg+xml;charset=utf-8,"+encodeURIComponent(source);
link.download = "clinical-timeline.svg";
link.href = url;
link.click();
$("#addtrack").css("visibility","visible");
} | javascript | {
"resource": ""
} | |
q54605 | train | function(download) {
$("#addtrack").css("visibility","hidden");
var element = document.getElementsByTagName('path')[0];
element.setAttribute("stroke" , "black");
element.setAttribute("fill" , "none");
element = document.getElementsByTagName('line');
for( var i=0 ; i<element.length ; i++)
{
element[i].setAttribute("stroke" , "black");
element[i].setAttribute("fill" , "none");
}
var svgString = new XMLSerializer().serializeToString(document.querySelector(spec.timelineDiv+" svg"));
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var DOMURL = self.URL || self.webkitURL || self;
var img = new Image();
var svg = new Blob([svgString], {type: "image/svg+xml;charset=utf-8"});
var url = DOMURL.createObjectURL(svg);
img.onload = function() {
ctx.drawImage(img, 0, 0);
var png = canvas.toDataURL("image/png");
document.querySelector("#png-container").innerHTML = '<img src="'+png+'"/>';
var link = document.createElement("a");
link.download = "clinical-timeline.png";
if (download) {
link.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
}
link.click();
DOMURL.revokeObjectURL(png);
link.remove();
};
img.src = url;
$("#addtrack").css("visibility","visible");
} | javascript | {
"resource": ""
} | |
q54606 | train | function() {
//to generate a PDF we first need to generate the canvas as done in generatePNG
//just don't need to download the PNG
this.generatePNG(false);
setTimeout(function(){
html2canvas($("#canvas"), {
onrendered: function(canvas) {
var canvas = document.getElementById("canvas");
var imgData = canvas.toDataURL(
'image/png');
var doc = new jsPDF('p', 'mm');
doc.addImage(imgData, 'PNG', 0, 0);
doc.save('clinical-timeline.pdf');
}
});
}, 50); //wait for 50ms for the canvas to be rendered before saving the PDF
} | javascript | {
"resource": ""
} | |
q54607 | zoomExplanation | train | function zoomExplanation(divId, svg, text, visibility, pos) {
d3.select(divId + " svg")
.insert("text")
.attr("transform", "translate("+(parseInt(svg.attr("width"))-pos)+", "+parseInt(svg.attr("height")-5)+")")
.attr("class", "timeline-label")
.text("")
.attr("id", "timelineZoomExplanation")
.text(text)
.style("visibility", visibility);
} | javascript | {
"resource": ""
} |
q54608 | train | function (pluginId, bool) {
timeline.plugins().forEach(function (element) {
if (pluginId === element.obj.id) {
element.enabled = bool;
}
});
timeline();
} | javascript | {
"resource": ""
} | |
q54609 | init | train | function init( element, value, bindings ) {
var $el = $( element );
var model = value();
var allBindings = unwrap( bindings() );
var options = ko.toJS( allBindings.froalaOptions );
// initialize the editor
$el.froalaEditor( options || {} );
// provide froala editor instance for flexibility
if( allBindings.froalaInstance && ko.isWriteableObservable( allBindings.froalaInstance ) ) {
allBindings.froalaInstance( $el.data( 'froala.editor' ) );
}
// update underlying model whenever editor content changed
var processUpdateEvent = function (e, editor) {
if (ko.isWriteableObservable(model)) {
var editorValue = editor.html.get();
var current = model();
if (current !== editorValue) {
model(editorValue);
}
}
}
$el.on('froalaEditor.contentChanged', processUpdateEvent);
$el.on('froalaEditor.paste.after', processUpdateEvent);
// cleanup editor, when dom node is removed
ko.utils.domNodeDisposal.addDisposeCallback( element, destroy( element ) );
// do not handle child nodes
return { controlsDescendantBindings: true };
} | javascript | {
"resource": ""
} |
q54610 | train | function (e, editor) {
if (ko.isWriteableObservable(model)) {
var editorValue = editor.html.get();
var current = model();
if (current !== editorValue) {
model(editorValue);
}
}
} | javascript | {
"resource": ""
} | |
q54611 | update | train | function update( element, value ) {
var $el = $( element );
var modelValue = unwrap( value() );
var editorInstance = $el.data( 'froala.editor' );
if( editorInstance == null ) {
return;
}
var editorValue = editorInstance.html.get();
// avoid any un-necessary updates
if( editorValue !== modelValue && (typeof modelValue === 'string' || modelValue === null)) {
editorInstance.html.set( modelValue );
}
} | javascript | {
"resource": ""
} |
q54612 | lazyDo | train | function lazyDo(fn, timeOut, doName, obj) {
var sto = null;
if (!obj) {
obj = window;
}
if (timeOut == null) {
timeOut = 25;
}
//If before the implementation of the operation has not exceeded the time,then make it cancel.
if (doName && obj[doName]) {
clearTimeout(obj[doName]);
}
//Delay for a period of time to perform the operation.
sto = setTimeout(function () {
fn.call(obj);
}, timeOut);
if (doName) {
obj[doName] = sto;
}
return sto;
} | javascript | {
"resource": ""
} |
q54613 | pollDo | train | function pollDo(fn, timeOut, doName, obj) {
var siv = null;
if (!obj) {
obj = window;
}
if (timeOut == null) {
timeOut = 100;
}
//If the previous poll operation is exist,then make it cancel.
if (doName && obj[doName]) {
clearInterval(obj[doName]);
}
//Polling execution operations every interval a period of time.
siv = setInterval(function () {
if (fn.call(obj) === false) {
clearInterval(siv);
}
}, timeOut);
if (doName) {
obj[doName] = siv;
}
return siv;
} | javascript | {
"resource": ""
} |
q54614 | on | train | function on(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).addEventListener(name, fn, useCapture);
} | javascript | {
"resource": ""
} |
q54615 | off | train | function off(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).removeEventListener(name, fn, useCapture);
} | javascript | {
"resource": ""
} |
q54616 | pageWidth | train | function pageWidth() {
return win.innerWidth != null ? win.innerWidth : doc.documentElement && doc.documentElement.clientWidth != null ? doc.documentElement.clientWidth : doc.body != null ? doc.body.clientWidth : null;
} | javascript | {
"resource": ""
} |
q54617 | pageHeight | train | function pageHeight() {
return win.innerHeight != null ? win.innerHeight : doc.documentElement && doc.documentElement.clientHeight != null ? doc.documentElement.clientHeight : doc.body != null ? doc.body.clientHeight : null;
} | javascript | {
"resource": ""
} |
q54618 | clone | train | function clone(item) {
if (!foundFirst && selectedKeys.indexOf(item.key) !== -1 || !foundFirst && !selectedKeys.length && firstActiveValue.indexOf(item.key) !== -1) {
foundFirst = true;
return Object(__WEBPACK_IMPORTED_MODULE_4_react__["cloneElement"])(item, {
ref: function ref(_ref) {
_this2.firstActiveItem = _ref;
}
});
}
return item;
} | javascript | {
"resource": ""
} |
q54619 | matches | train | function matches(elem, selector) {
// Vendor-specific implementations of `Element.prototype.matches()`.
var proto = window.Element.prototype;
var nativeMatches = proto.matches ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector;
if (!elem || elem.nodeType !== 1) {
return false;
}
var parentElem = elem.parentNode;
// use native 'matches'
if (nativeMatches) {
return nativeMatches.call(elem, selector);
}
// native support for `matches` is missing and a fallback is required
var nodes = parentElem.querySelectorAll(selector);
var len = nodes.length;
for (var i = 0; i < len; i++) {
if (nodes[i] === elem) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q54620 | insert | train | function insert(target, host, fn) {
var i = 0, self = host || this, r = []
// target nodes could be a css selector if it's a string and a selector engine is present
// otherwise, just use target
, nodes = query && typeof target == 'string' && target.charAt(0) != '<' ? query(target) : target
// normalize each node in case it's still a string and we need to create nodes on the fly
each(normalize(nodes), function (t) {
each(self, function (el) {
var n = !el[parentNode] || (el[parentNode] && !el[parentNode][parentNode]) ?
function () {
var c = el.cloneNode(true)
// check for existence of an event cloner
// preferably https://github.com/fat/bean
// otherwise Bonzo won't do this for you
self.$ && self.cloneEvents && self.$(c).cloneEvents(el)
return c
}() : el
fn(t, n)
r[i] = n
i++
})
}, this)
each(r, function (e, i) {
self[i] = e
})
self.length = i
return self
} | javascript | {
"resource": ""
} |
q54621 | each | train | function each(a, fn) {
var i = 0, l = a.length
for (; i < l; i++) fn.call(null, a[i])
} | javascript | {
"resource": ""
} |
q54622 | _qwery | train | function _qwery(selector, _root) {
var r = [], ret = [], i, l, m, token, tag, els, intr, item, root = _root
, tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
, dividedTokens = selector.match(dividers)
if (!tokens.length) return r
token = (tokens = tokens.slice(0)).pop() // copy cached tokens, take the last one
if (tokens.length && (m = tokens[tokens.length - 1].match(idOnly))) root = byId(_root, m[1])
if (!root) return r
intr = q(token)
// collect base candidates to filter
els = root !== _root && root.nodeType !== 9 && dividedTokens && /^[+~]$/.test(dividedTokens[dividedTokens.length - 1]) ?
function (r) {
while (root = root.nextSibling) {
root.nodeType == 1 && (intr[1] ? intr[1] == root.tagName.toLowerCase() : 1) && (r[r.length] = root)
}
return r
}([]) :
root[byTag](intr[1] || '*')
// filter elements according to the right-most part of the selector
for (i = 0, l = els.length; i < l; i++) {
if (item = interpret.apply(els[i], intr)) r[r.length] = item
}
if (!tokens.length) return r
// filter further according to the rest of the selector (the left side)
each(r, function(e) { if (ancestorMatch(e, tokens, dividedTokens)) ret[ret.length] = e })
return ret
} | javascript | {
"resource": ""
} |
q54623 | crawl | train | function crawl(e, i, p) {
while (p = walker[dividedTokens[i]](p, e)) {
if (isNode(p) && (interpret.apply(p, q(tokens[i])))) {
if (i) {
if (cand = crawl(p, i - 1, p)) return cand
} else return p
}
}
} | javascript | {
"resource": ""
} |
q54624 | train | function (checkNamespaces) {
var i, j
if (!checkNamespaces)
return true
if (!this.namespaces)
return false
for (i = checkNamespaces.length; i--;) {
for (j = this.namespaces.length; j--;) {
if (checkNamespaces[i] === this.namespaces[j])
return true
}
}
return false
} | javascript | {
"resource": ""
} | |
q54625 | train | function () {
var i, entries = registry.entries()
for (i in entries) {
if (entries[i].type && entries[i].type !== 'unload')
remove(entries[i].element, entries[i].type)
}
win[detachEvent]('onunload', cleanup)
win.CollectGarbage && win.CollectGarbage()
} | javascript | {
"resource": ""
} | |
q54626 | train | function (name, table, condition, opts) {
opts = opts || {};
if (name) {
name = sql.stringToIdentifier(name);
if (table && condition) {
opts = comb.merge({joinType: "left", table: table, condition: condition, column: name}, opts);
this._mappedColumns[name] = opts;
} else {
throw new ModelError("mapped column requires a table and join condition");
}
}
return this;
} | javascript | {
"resource": ""
} | |
q54627 | train | function () {
if (!this.__serverVersion) {
var self = this;
this.__serverVersion = this.get(identifier("version").sqlFunction).chain(function (version) {
var m = version.match(/PostgreSQL (\d+)\.(\d+)(?:(?:rc\d+)|\.(\d+))?/);
version = (parseInt(m[1], 10) * 10000) + (parseInt(m[2], 10) * 100) + parseInt(m[3], 10);
self._serverVersion = version;
return version;
});
}
return this.__serverVersion.promise();
} | javascript | {
"resource": ""
} | |
q54628 | train | function (type, opts, cb) {
var ret;
var ds = this.metadataDataset.from("pg_class")
.filter({relkind: type}).select("relname")
.exclude({relname: {like: this.SYSTEM_TABLE_REGEXP}})
.join("pg_namespace", {oid: identifier("relnamespace")});
ds = this.__filterSchema(ds, opts);
var m = this.outputIdentifierFunc;
if (cb) {
ret = when(cb(ds));
} else {
ret = ds.map(function (r) {
return m(r.relname);
});
}
return ret.promise();
} | javascript | {
"resource": ""
} | |
q54629 | train | function (column) {
if (column.fixed) {
return ["char(", column.size || 255, ")"].join("");
} else if (column.text === false || column.size) {
return ["varchar(", column.size || 255, ")"].join("");
} else {
return 'text';
}
} | javascript | {
"resource": ""
} | |
q54630 | train | function (parent) {
var options = this.__opts || {};
var ds, self = this;
if (!isUndefined((ds = options.dataset)) && isFunction(ds)) {
ds = ds.apply(parent, [parent]);
}
if (!ds) {
var q = {};
this._setAssociationKeys(parent, q);
ds = this.model.dataset.naked().filter(q);
var recip = this.model._findAssociation(this);
recip && (recip = recip[1]);
ds.rowCb = function (item) {
var model = self._toModel(item, true);
recip && recip.__setValue(model, parent);
//call hook to finish other model associations
return model._hook("post", "load").chain(function () {
return model;
});
};
} else if (!ds.rowCb && this.model) {
ds.rowCb = function (item) {
var model = self._toModel(item, true);
//call hook to finish other model associations
return model._hook("post", "load").chain(function () {
return model;
});
};
}
return this._setDatasetOptions(ds);
} | javascript | {
"resource": ""
} | |
q54631 | train | function (model) {
//if we have them return them;
if (this.associationLoaded(model)) {
var assoc = this.getAssociation(model);
return this.isEager() ? assoc : when(assoc);
} else if (model.isNew) {
return null;
} else {
return this.fetch(model);
}
} | javascript | {
"resource": ""
} | |
q54632 | train | function (parent, name) {
this.name = name;
var self = this;
this.parent = parent;
var parentProto = parent.prototype;
parentProto["__defineGetter__"](name, function () {
return self._getter(this);
});
parentProto["__defineGetter__"](this.associatedDatasetName, function () {
return self._filter(this);
});
if (!this.readOnly && this.createSetter) {
//define a setter because we arent read only
parentProto["__defineSetter__"](name, function (vals) {
self._setter(vals, this);
});
}
//set up all callbacks
["pre", "post"].forEach(function (op) {
["save", "update", "remove", "load"].forEach(function (type) {
parent[op](type, function (next) {
return self["_" + op + type.charAt(0).toUpperCase() + type.slice(1)](next, this);
});
}, this);
}, this);
} | javascript | {
"resource": ""
} | |
q54633 | train | function () {
var q = this._getPrimaryKeyQuery();
return new PromiseList(this._static.__ctiTables.slice().reverse().map(function (table) {
return this.db.from(table).filter(q).remove();
}, this), true).promise();
} | javascript | {
"resource": ""
} | |
q54634 | train | function () {
var Self = this._static, ret;
if (Self === Self.__ctiBaseModel) {
ret = this._super(arguments);
} else {
var pk = this.primaryKey[0], tables = Self.__ctiTables, ctiColumns = Self.__ctiColumns, self = this,
isRestricted = Self.isRestrictedPrimaryKey, db = this.db;
ret = asyncArray.forEach(tables,function (table, index) {
var cols = ctiColumns[table], insert = {}, val, i = -1, colLength = cols.length, c;
while (++i < colLength) {
c = cols[i];
if ((index !== 0 || (index === 0 && (!isRestricted || pk.indexOf(c) === -1))) && !comb.isUndefined(val = self[c])) {
insert[c] = val;
}
}
return db.from(table).insert(insert).chain(function (id) {
if (comb.isUndefined(self.primaryKeyValue) && !comb.isUndefined(id) && index === 0) {
self.__ignore = true;
//how to handle composite keys.
self[pk] = id;
self.__ignore = false;
}
});
}, 1).chain(function () {
self.__isNew = false;
self.__isChanged = false;
return self._saveReload();
});
}
return ret.promise();
} | javascript | {
"resource": ""
} | |
q54635 | train | function () {
var q = this._getPrimaryKeyQuery(), changed = this.__changed;
var modelStatic = this._static,
ctiColumns = modelStatic.__ctiColumns,
tables = modelStatic.__ctiTables,
self = this;
return new PromiseList(tables.map(function (table) {
var cols = ctiColumns[table], update = {};
cols.forEach(function (c) {
if (!comb.isUndefined(changed[c])) {
update[c] = changed[c];
}
});
return comb.isEmpty(update) ? new Promise().callback() : self.db.from(table).filter(q).update(update);
}), true)
.chain(function () {
return self._updateReload();
})
.promise();
} | javascript | {
"resource": ""
} | |
q54636 | train | function (tableAlias) {
tableAlias = this._toTableName(tableAlias);
var usedAliases = [], from, join;
if ((from = this.__opts.from) != null) {
usedAliases = usedAliases.concat(from.map(function (n) {
return this._toTableName(n);
}, this));
}
if ((join = this.__opts.join) != null) {
usedAliases = usedAliases.concat(join.map(function (join) {
if (join.tableAlias) {
return this.__toAliasedTableName(join.tableAlias);
} else {
return this._toTableName(join.table);
}
}, this));
}
if (usedAliases.indexOf(tableAlias) !== -1) {
var base = tableAlias, i = 0;
do {
tableAlias = string.format("%s%d", base, i++);
} while (usedAliases.indexOf(tableAlias) !== -1);
}
return tableAlias;
} | javascript | {
"resource": ""
} | |
q54637 | train | function (v) {
if (isInstanceOf(v, Json, JsonArray)) {
return this._literalJson(v);
} else if (isInstanceOf(v, LiteralString)) {
return "" + v;
} else if (isString(v)) {
return this._literalString(v);
} else if (isNumber(v)) {
return this._literalNumber(v);
} else if (isInstanceOf(v, Expression)) {
return this._literalExpression(v);
} else if (isInstanceOf(v, Dataset)) {
return this._literalDataset(v);
} else if (isArray(v)) {
return this._literalArray(v);
} else if (isInstanceOf(v, sql.Year)) {
return this._literalYear(v);
} else if (isInstanceOf(v, sql.TimeStamp, sql.DateTime)) {
return this._literalTimestamp(v);
} else if (isDate(v)) {
return this._literalDate(v);
} else if (isInstanceOf(v, sql.Time)) {
return this._literalTime(v);
} else if (Buffer.isBuffer(v)) {
return this._literalBuffer(v);
} else if (isNull(v)) {
return this._literalNull();
} else if (isBoolean(v)) {
return this._literalBoolean(v);
} else if (isHash(v)) {
return this._literalObject(v);
} else {
return this._literalOther(v);
}
} | javascript | {
"resource": ""
} | |
q54638 | train | function (name) {
var ret;
if (isString(name)) {
var parts = this._splitString(name);
var schema = parts[0], table = parts[1], alias = parts[2];
ret = (schema || alias) ? alias || table : table;
} else if (isInstanceOf(name, Identifier)) {
ret = name.value;
} else if (isInstanceOf(name, QualifiedIdentifier)) {
ret = this._toTableName(name.column);
} else if (isInstanceOf(name, AliasedExpression)) {
ret = this.__toAliasedTableName(name.alias);
} else {
throw new QueryError("Invalid object to retrieve the table name from");
}
return ret;
} | javascript | {
"resource": ""
} | |
q54639 | train | function (type) {
var sql = [("" + type).toUpperCase()];
try {
this._static[sql + "_CLAUSE_METHODS"].forEach(function (m) {
if (m.match("With")) {
this[m](sql);
} else {
var sqlRet = this[m]();
if (sqlRet) {
sql.push(sqlRet);
}
}
}, this);
} catch (e) {
throw e;
}
return sql.join("");
} | javascript | {
"resource": ""
} | |
q54640 | train | function (sql) {
var columns = this.__opts.columns, ret = "";
if (columns && columns.length) {
ret = " (" + columns.map(
function (c) {
return c.toString(this);
}, this).join(this._static.COMMA_SEPARATOR) + ")";
}
return ret;
} | javascript | {
"resource": ""
} | |
q54641 | train | function () {
var values = this.__opts.values, ret = [];
if (isArray(values)) {
ret.push(values.length === 0 ? " DEFAULT VALUES" : " VALUES " + this.literal(values));
} else if (isInstanceOf(values, Dataset)) {
ret.push(" " + this._subselectSql(values));
} else if (isInstanceOf(values, LiteralString)) {
ret.push(" " + values.toString(this));
} else {
throw new QueryError("Unsupported INSERT values type, should be an array or dataset");
}
return ret.join("");
} | javascript | {
"resource": ""
} | |
q54642 | train | function (source) {
if (!Array.isArray(source)) {
source = [source];
}
if (!source || !source.length) {
throw new QueryError("No source specified for the query");
}
return " " + source.map(
function (s) {
return this.__tableRef(s);
}, this).join(this._static.COMMA_SEPARATOR);
} | javascript | {
"resource": ""
} | |
q54643 | train | function (db) {
//create a table called state;
return db
.createTable("state", function () {
this.primaryKey("id");
this.name(String);
this.population("integer");
this.founded(Date);
this.climate(String);
this.description("text");
})
.chain(function () {
//create another table called capital
return db.createTable("capital", function () {
this.primaryKey("id");
this.population("integer");
this.name(String);
this.founded(Date);
this.foreignKey("stateId", "state", {key: "id", onDelete: "CASCADE"});
});
});
} | javascript | {
"resource": ""
} | |
q54644 | train | function (db, directory, opts) {
this.db = db;
this.directory = directory;
opts = opts || {};
this.table = opts.table || this._static.DEFAULT_SCHEMA_TABLE;
this.column = opts.column || this._static.DEFAULT_SCHEMA_COLUMN;
this._opts = opts;
} | javascript | {
"resource": ""
} | |
q54645 | train | function () {
if (!this.__schemaDataset) {
var ds = this.db.from(this.table), self = this;
return this.__createTable().chain(function () {
return (self.__schemaDataset = ds);
});
} else {
return when(this.__schemaDataset);
}
} | javascript | {
"resource": ""
} | |
q54646 | train | function (obj) {
return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) {
return isArray(i) && i.length === 2;
}));
} | javascript | {
"resource": ""
} | |
q54647 | train | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.castSql(this.expr, this.type);
} | javascript | {
"resource": ""
} | |
q54648 | train | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.complexExpressionSql(this.op, this.args);
} | javascript | {
"resource": ""
} | |
q54649 | train | function (args) {
args = argsToArray(arguments);
if (args.length && !this.supportsDistinctOn) {
throw new QueryError("DISTICT ON is not supported");
}
args = args.map(function (a) {
return isString(a) ? new Identifier(a) : a;
});
return this.mergeOptions({distinct: args});
} | javascript | {
"resource": ""
} | |
q54650 | train | function(includeDatasets, fromModel) {
var ds = this.mergeOptions({}),
originalRowCb = ds.rowCb;
if(!ds.__opts._eagerAssoc) {
ds.__opts._eagerAssoc = includeDatasets;
ds.rowCb = function (topLevelResults) {
function toObject(thing) {
if (!thing) {
return comb.when(thing);
}
if (Array.isArray(thing)) {
return comb.when(thing.map(function(item) {
return toObject(item);
}));
}
if ('toObject' in thing) {
return comb.when(thing.toObject());
}
return comb.when(thing);
}
var eagerResults = {},
whens = [];
if (!originalRowCb) {
// pass through for when topLevelResults is already resolved
originalRowCb = function(r){return r;};
}
return comb.when(originalRowCb(topLevelResults)).chain(function(maybeModel) {
whens = Object.keys(ds.__opts._eagerAssoc).map(function(key) {
return ds.__opts._eagerAssoc[key](maybeModel).chain(function(result) {
return toObject(result).chain(function(res) {
eagerResults[key] = res;
return result;
});
});
});
return comb.when(whens).chain(function () {
return toObject(maybeModel).chain(function(json) {
// merge associations on to main data
return Object.assign(json, eagerResults);
});
});
});
};
}
return ds.mergeOptions({
_eagerAssoc: Object.assign(ds.__opts._eagerAssoc, includeDatasets)
});
} | javascript | {
"resource": ""
} | |
q54651 | train | function (args, cb) {
args = [this.__opts["having"] ? "having" : "where"].concat(argsToArray(arguments));
return this._filter.apply(this, args);
} | javascript | {
"resource": ""
} | |
q54652 | train | function (opts) {
opts = isUndefined(opts) ? {} : opts;
var fs = {};
var nonSqlOptions = this._static.NON_SQL_OPTIONS;
Object.keys(this.__opts).forEach(function (k) {
if (nonSqlOptions.indexOf(k) === -1) {
fs[k] = null;
}
});
return this.mergeOptions(fs).from(opts["alias"] ? this.as(opts["alias"]) : this);
} | javascript | {
"resource": ""
} | |
q54653 | train | function (columns) {
columns = argsToArray(arguments);
var group = this.group.apply(this, columns.map(function (c) {
return this._unaliasedIdentifier(c);
}, this));
return group.select.apply(group, columns.concat([this._static.COUNT_OF_ALL_AS_COUNT]));
} | javascript | {
"resource": ""
} | |
q54654 | train | function (dataset, opts) {
opts = isUndefined(opts) ? {} : opts;
if (!isHash(opts)) {
opts = {all: opts};
}
if (!this.supportsIntersectExcept) {
throw new QueryError("INTERSECT not supported");
} else if (opts.all && !this.supportsIntersectExceptAll) {
throw new QueryError("INTERSECT ALL not supported");
}
return this.compoundClone("intersect", dataset, opts);
} | javascript | {
"resource": ""
} | |
q54655 | train | function () {
var having = this.__opts.having, where = this.__opts.where;
if (!(having || where)) {
throw new QueryError("No current filter");
}
var o = {};
if (having) {
o.having = BooleanExpression.invert(having);
}
if (where) {
o.where = BooleanExpression.invert(where);
}
return this.mergeOptions(o);
} | javascript | {
"resource": ""
} | |
q54656 | train | function (limit, offset) {
if (this.__opts.sql) {
return this.fromSelf().limit(limit, offset);
}
if (Array.isArray(limit) && limit.length === 2) {
offset = limit[0];
limit = limit[1] - limit[0] + 1;
}
if (isString(limit) || isInstanceOf(limit, LiteralString)) {
limit = parseInt("" + limit, 10);
}
if (isNumber(limit) && limit < 1) {
throw new QueryError("Limit must be >= 1");
}
var opts = {limit: limit};
if (offset) {
if (isString(offset) || isInstanceOf(offset, LiteralString)) {
offset = parseInt("" + offset, 10);
isNaN(offset) && (offset = 0);
}
if (isNumber(offset) && offset < 0) {
throw new QueryError("Offset must be >= 0");
}
opts.offset = offset;
}
return this.mergeOptions(opts);
} | javascript | {
"resource": ""
} | |
q54657 | train | function (table) {
var o = this.__opts;
if (o.sql) {
return this.mergeOptions();
}
var h = {};
array.intersect(Object.keys(o), this._static.QUALIFY_KEYS).forEach(function (k) {
h[k] = this._qualifiedExpression(o[k], table);
}, this);
if (!o.select || isEmpty(o.select)) {
h.select = [new ColumnAll(table)];
}
return this.mergeOptions(h);
} | javascript | {
"resource": ""
} | |
q54658 | train | function (args) {
args = argsToArray(arguments);
return this.order.apply(this, this._invertOrder(args.length ? args : this.__opts.order));
} | javascript | {
"resource": ""
} | |
q54659 | train | function (cols) {
var ret;
if (!this.hasSelectSource) {
ret = this.select.apply(this, arguments);
} else {
ret = this.mergeOptions();
}
return ret;
} | javascript | {
"resource": ""
} | |
q54660 | train | function (cols) {
cols = argsToArray(arguments);
var currentSelect = this.__opts.select;
return this.select.apply(this, (currentSelect || []).concat(cols));
} | javascript | {
"resource": ""
} | |
q54661 | train | function (type, dataset, options) {
var ds = this._compoundFromSelf().mergeOptions({compounds: (array.toArray(this.__opts.compounds || [])).concat([
[type, dataset._compoundFromSelf(), options.all]
])});
return options.fromSelf === false ? ds : ds.fromSelf(options);
} | javascript | {
"resource": ""
} | |
q54662 | train | function (op, obj) {
var pairs = [];
if (Expression.isConditionSpecifier(obj)) {
if (isHash(obj)) {
obj = array.toArray(obj);
}
obj.forEach(function (pair) {
pairs.push(new BooleanExpression(op, new Identifier(pair[0]), pair[1]));
});
}
return pairs.length === 1 ? pairs[0] : BooleanExpression.fromArgs(["AND"].concat(pairs));
} | javascript | {
"resource": ""
} | |
q54663 | train | function (name, type, opts) {
opts = opts || {};
this.columns.push(merge({name:name, type:type}, opts));
if (opts.index) {
this.index(name);
}
} | javascript | {
"resource": ""
} | |
q54664 | train | function (name) {
if (Array.isArray(name)) {
return this.__compositePrimaryKey.apply(this, arguments);
} else {
var args = argsToArray(arguments, 1), type;
var opts = args.pop();
this.__primaryKey = merge({}, this.db.serialPrimaryKeyOptions, {name:name}, opts);
if (isDefined((type = args.pop()))) {
merge(opts, {type:type});
}
merge(this.__primaryKey, opts);
return this.__primaryKey;
}
} | javascript | {
"resource": ""
} | |
q54665 | train | function (name, newName, opts) {
opts = opts || {};
this.operations.push(merge({op:"renameColumn", name:name, newName:newName}, opts));
} | javascript | {
"resource": ""
} | |
q54666 | train | function (name, type, opts) {
opts = opts || {};
this.operations.push(merge({op:"setColumnType", name:name, type:type}, opts));
} | javascript | {
"resource": ""
} | |
q54667 | train | function () {
if (!this.__isNew) {
var self = this;
return this.dataset.naked().filter(this._getPrimaryKeyQuery()).one().chain(function (values) {
self.__setFromDb(values, true);
return self;
});
} else {
return when(this);
}
} | javascript | {
"resource": ""
} | |
q54668 | train | function (vals, /*?object*/query, options) {
options = options || {};
var dataset = this.dataset;
return this._checkTransaction(options, function () {
if (!isUndefined(query)) {
dataset = dataset.filter(query);
}
return dataset.update(vals);
});
} | javascript | {
"resource": ""
} | |
q54669 | train | function (id, options) {
var self = this;
return this._checkTransaction(options, function () {
return self.findById(id).chain(function (model) {
return model ? model.remove(options) : null;
});
});
} | javascript | {
"resource": ""
} | |
q54670 | train | function (items, options) {
options = options || {};
var isArr = isArray(items), Self = this;
return this._checkTransaction(options, function () {
return asyncArray(items)
.map(function (o) {
if (!isInstanceOf(o, Self)) {
o = new Self(o);
}
return o.save(null, options);
})
.chain(function (res) {
return isArr ? res : res[0];
});
});
} | javascript | {
"resource": ""
} | |
q54671 | train | function (dt, format) {
var ret = "";
if (isInstanceOf(dt, SQL.Time)) {
ret = this.timeToString(dt, format);
} else if (isInstanceOf(dt, SQL.Year)) {
ret = this.yearToString(dt, format);
} else if (isInstanceOf(dt, SQL.DateTime)) {
ret = this.dateTimeToString(dt, format);
} else if (isInstanceOf(dt, SQL.TimeStamp)) {
ret = this.timeStampToString(dt, format);
} else if (isDate(dt)) {
ret = dateFormat(dt, format || this.dateFormat);
}
return ret;
} | javascript | {
"resource": ""
} | |
q54672 | train | function (dt, format) {
var ret;
if (this.convertTwoDigitYears) {
ret = date.parse(dt, this.TWO_YEAR_DATE_FORMAT);
}
if (!ret) {
ret = date.parse(dt, format || this.dateFormat);
}
if (!ret) {
throw new PatioError("Unable to convert date: " + dt);
}
return ret;
} | javascript | {
"resource": ""
} | |
q54673 | train | function (args) {
args = argsToArray(arguments);
return !args.length ? this._super(arguments) : this.group.apply(this, args);
} | javascript | {
"resource": ""
} | |
q54674 | train | function (cols, terms, opts) {
opts = opts || {};
cols = toArray(cols).map(this.stringToIdentifier, this);
return this.filter(sql.literal(this.fullTextSql(cols, terms, opts)));
} | javascript | {
"resource": ""
} | |
q54675 | train | function (cols, term, opts) {
opts = opts || {};
return format("MATCH %s AGAINST (%s%s)", this.literal(toArray(cols)),
this.literal(toArray(term).join(" ")), opts.boolean ? " IN BOOLEAN MODE" : "");
} | javascript | {
"resource": ""
} | |
q54676 | train | function (columns, values) {
return [this.insertSql(columns, sql.literal('VALUES ' + values.map(
function (r) {
return this.literal(toArray(r));
}, this).join(this._static.COMMA_SEPARATOR)))];
} | javascript | {
"resource": ""
} | |
q54677 | train | function (sql) {
if (this._joinedDataset) {
return format(" %s FROM %s%s", this._sourceList(this.__opts.from[0]), this._sourceList(this.__opts.from), this._selectJoinSql());
} else {
return this._super(arguments);
}
} | javascript | {
"resource": ""
} | |
q54678 | train | function (sql) {
var values = this.__opts.values;
if (isArray(values) && !values.length) {
return " ()";
} else {
return this._super(arguments);
}
} | javascript | {
"resource": ""
} | |
q54679 | train | function () {
var ret = "";
var updateCols = this.__opts.onDuplicateKeyUpdate;
if (updateCols) {
var updateVals = null, l, last;
if ((l = updateCols.length) > 0 && isHash((last = updateCols[l - 1]))) {
updateVals = last;
updateCols = l === 2 ? [updateCols[0]] : updateCols.slice(0, l - 2);
}
var updating = updateCols.map(function (c) {
var quoted = this.quoteIdentifier(c);
return format("%s=VALUES(%s)", quoted, quoted);
}, this);
for (var i in updateVals) {
if (i in updateVals) {
updating.push(format("%s=%s", this.quoteIdentifier(i), this.literal(updateVals[i])));
}
}
if (updating || updateVals) {
ret =
format(" ON DUPLICATE KEY UPDATE %s", updating.join(this._static.COMMA_SEPARATOR));
}
}
return ret;
} | javascript | {
"resource": ""
} | |
q54680 | train | function (type) {
var ret = null, meth;
if (isString(type)) {
ret = this._static.CAST_TYPES[type] || this._super(arguments);
} else if (type === String) {
meth += "CHAR";
} else if (type === Number) {
meth += "DECIMAL";
} else if (type === DateTime) {
meth += "DATETIME";
} else if (type === Year) {
meth += "Year";
} else if (type === Time) {
meth += "DATETIME";
} else if (type === Double) {
meth += "DECIMAL";
} else {
ret = this._super(arguments);
}
return ret;
} | javascript | {
"resource": ""
} | |
q54681 | train | function (table, opts) {
var indexes = {};
var removeIndexes = [];
var m = this.outputIdentifierFunc;
var im = this.inputIdentifierFunc;
return this.metadataDataset.withSql("SHOW INDEX FROM ?", isInstanceOf(table, sql.Identifier) ? table : sql.identifier(im(table)))
.forEach(function (r) {
var name = r[m("Key_name")];
if (name !== "PRIMARY") {
name = m(name);
if (r[m("Sub_part")]) {
removeIndexes.push(name);
}
var i = indexes[name] || (indexes[name] = {columns: [], unique: r[m("Non_unique")] !== 1});
i.columns.push(m(r[m("Column_name")]));
}
}).chain(function () {
var r = {};
for (var i in indexes) {
if (removeIndexes.indexOf(i) === -1) {
r[i] = indexes[i];
}
}
return r;
});
} | javascript | {
"resource": ""
} | |
q54682 | train | function () {
var ret;
if (!this.__serverVersion) {
var self = this;
ret = this.get(sql.version().sqlFunction).chain(function (version) {
var m = version.match(/(\d+)\.(\d+)\.(\d+)/);
return (self._serverVersion = (parseInt(m[1], 10) * 10000) + (parseInt(m[2], 10) * 100) + parseInt(m[3], 10));
});
} else {
ret = new Promise().callback(this._serverVersion);
}
return ret.promise();
} | javascript | {
"resource": ""
} | |
q54683 | train | function (opts) {
var m = this.outputIdentifierFunc;
return this.metadataDataset.withSql('SHOW TABLES').map(function (r) {
return m(r[Object.keys(r)[0]]);
});
} | javascript | {
"resource": ""
} | |
q54684 | train | function (table, op) {
var ret = new Promise(), self = this;
if (op.op === "addColumn") {
var related = op.table;
if (related) {
delete op.table;
ret = this._super(arguments).chain(function (sql) {
op.table = related;
return [sql, format("ALTER TABLE %s ADD FOREIGN KEY (%s)%s",
self.__quoteSchemaTable(table), self.__quoteIdentifier(op.name),
self.__columnReferencesSql(op))];
});
} else {
ret = this._super(arguments);
}
} else if (['renameColumn', "setColumnType", "setColumnNull", "setColumnDefault"].indexOf(op.op) !== -1) {
ret = this.schema(table).chain(function (schema) {
var name = op.name;
var opts = schema[Object.keys(schema).filter(function (i) {
return i === name;
})[0]];
opts = merge({}, opts || {});
opts.name = op.newName || name;
opts.type = op.type || opts.dbType;
opts.allowNull = isUndefined(op["null"]) ? opts.allowNull : op["null"];
opts["default"] = op["default"] || opts.jsDefault;
if (isUndefinedOrNull(opts["default"])) {
delete opts["default"];
}
return format("ALTER TABLE %s CHANGE COLUMN %s %s", self.__quoteSchemaTable(table),
self.__quoteIdentifier(op.name), self.__columnDefinitionSql(merge(op, opts)));
});
} else if (op.op === "dropIndex") {
ret = when(format("%s ON %s", this.__dropIndexSql(table, op), this.__quoteSchemaTable(table)));
} else {
ret = this._super(arguments);
}
return ret.promise();
} | javascript | {
"resource": ""
} | |
q54685 | train | function (conn, opts) {
var self = this;
return this.__setTransactionIsolation(conn, opts).chain(function () {
return self.__logConnectionExecute(conn, self.beginTransactionSql);
});
} | javascript | {
"resource": ""
} | |
q54686 | train | function (column) {
if (isString(column.type) && column.type.match(/string/i) && column.text) {
delete column["default"];
}
return this._super(arguments, [column]);
} | javascript | {
"resource": ""
} | |
q54687 | train | function (conn, opts) {
opts = opts || {};
var s = opts.prepare, self = this;
if (s) {
return this.__logConnectionExecute(conn, comb("XA END %s").format(this.literal(s))).chain(function () {
return self.__logConnectionExecute(comb("XA PREPARE %s").format(self.literal(s)));
});
} else {
return this._super(arguments);
}
} | javascript | {
"resource": ""
} | |
q54688 | train | function (name, generator, options) {
options = options || {};
var engine = options.engine, charset = options.charset, collate = options.collate;
if (isUndefined(engine)) {
engine = this._static.defaultEngine;
}
if (isUndefined(charset)) {
charset = this._static.defaultCharset;
}
if (isUndefined(collate)) {
collate = this._static.defaultCollate;
}
generator.columns.forEach(function (c) {
var t = c.table;
if (t) {
delete c.table;
generator.foreignKey([c.name], t, merge({}, c, {name: null, type: "foreignKey"}));
}
});
return format(" %s%s%s%s", this._super(arguments), engine ? " ENGINE=" + engine : "",
charset ? " DEFAULT CHARSET=" + charset : "", collate ? " DEFAULT COLLATE=" + collate : "");
} | javascript | {
"resource": ""
} | |
q54689 | train | function (tableName, index) {
var indexName = this.__quoteIdentifier(index.name || this.__defaultIndexName(tableName,
index.columns)), t = index.type, using = "";
var indexType = "";
if (t === "fullText") {
indexType = "FULLTEXT ";
} else if (t === "spatial") {
indexType = "SPATIAL ";
} else {
indexType = index.unique ? "UNIQUE " : "";
using = t ? " USING " + t : "";
}
return format("CREATE %sINDEX %s%s ON %s %s", indexType, indexName, using,
this.__quoteSchemaTable(tableName), this.literal(index.columns.map(function (c) {
return isString(c) ? sql.identifier(c) : c;
})));
} | javascript | {
"resource": ""
} | |
q54690 | train | function (conn, opts) {
opts = opts || {};
var s = opts.prepare;
var logConnectionExecute = comb("__logConnectionExecute");
if (s) {
s = this.literal(s);
var self = this;
return this.__logConnectionExecute(conn, "XA END " + s)
.chain(function () {
return self.__logConnectionExecute(conn, "XA PREPARE " + s);
})
.chain(function () {
return self.__logConnectionExecute(conn, "XA ROLLBACK " + s);
});
} else {
return this._super(arguments);
}
} | javascript | {
"resource": ""
} | |
q54691 | train | function (tableName, opts) {
var m = this.outputIdentifierFunc, im = this.inputIdentifierFunc, self = this;
return this.metadataDataset.withSql("DESCRIBE ?", sql.identifier(im(tableName))).map(function (row) {
var ret = {};
var e = row[m("Extra")];
var allowNull = row[m("Null")];
var key = row[m("Key")];
ret.autoIncrement = e.match(/auto_increment/i) !== null;
ret.allowNull = allowNull.match(/Yes/i) !== null;
ret.primaryKey = key.match(/PRI/i) !== null;
var defaultValue = row[m("Default")];
ret["default"] = Buffer.isBuffer(defaultValue) ? defaultValue.toString() : defaultValue;
if (isEmpty(row["default"])) {
row["default"] = null;
}
ret.dbType = row[m("Type")];
if (Buffer.isBuffer(ret.dbType)) {
//handle case for field type being returned at 252 (i.e. BLOB)
ret.dbType = ret.dbType.toString();
}
ret.type = self.schemaColumnType(ret.dbType.toString("utf8"));
var fieldName = m(row[m("Field")]);
return [fieldName, ret];
});
} | javascript | {
"resource": ""
} | |
q54692 | train | function (block, cb) {
var self = this;
var ret = asyncArray(this.forEach().chain(function (records) {
return self.postLoad(records);
}));
if (block) {
ret = ret.forEach(block);
}
return ret.classic(cb).promise();
} | javascript | {
"resource": ""
} | |
q54693 | train | function (cb) {
return this.__aggregateDataset().get(sql.COUNT(sql.literal("*")).as("count")).chain(function (res) {
return parseInt(res, 10);
}).classic(cb);
} | javascript | {
"resource": ""
} | |
q54694 | train | function (block, cb) {
var rowCb, ret;
if (this.__opts.graph) {
ret = this.graphEach(block);
} else {
ret = this.fetchRows(this.selectSql);
if ((rowCb = this.rowCb)) {
ret = ret.map(function (r) {
return rowCb(r);
});
}
if (block) {
ret = ret.forEach(block);
}
}
return ret.classic(cb);
} | javascript | {
"resource": ""
} | |
q54695 | train | function (args) {
args = comb(arguments).toArray();
var cb,
block = isFunction(args[args.length - 1]) ? args.pop() : null;
if (block && block.length > 0) {
cb = block;
block = isFunction(args[args.length - 1]) ? args.pop() : null;
}
var ds = block ? this.filter(block) : this;
if (!args.length) {
return ds.singleRecord(cb);
} else {
args = (args.length === 1) ? args[0] : args;
if (isNumber(args)) {
return ds.limit(args).all(null, cb);
} else {
return ds.filter(args).singleRecord(cb);
}
}
} | javascript | {
"resource": ""
} | |
q54696 | train | function (columns, values, opts, cb) {
if (isFunction(opts)) {
cb = opts;
opts = null;
}
opts = opts || {};
var ret, self = this;
if (isInstanceOf(values, Dataset)) {
ret = this.db.transaction(function () {
return self.insert(columns, values);
});
} else {
if (!values.length) {
ret = new Promise().callback();
} else if (!columns.length) {
throw new QueryError("Invalid columns in import");
}
var sliceSize = opts.commitEvery || opts.slice, result = [];
if (sliceSize) {
ret = asyncArray(partition(values, sliceSize)).forEach(function (entries, offset) {
offset = (offset * sliceSize);
return self.db.transaction(opts, function () {
return when(self.multiInsertSql(columns, entries).map(function (st, index) {
return self.executeDui(st).chain(function (res) {
result[offset + index] = res;
});
}));
});
}, 1);
} else {
var statements = this.multiInsertSql(columns, values);
ret = this.db.transaction(function () {
return when(statements.map(function (st, index) {
return self.executeDui(st).chain(function (res) {
result[index] = res;
});
}));
});
}
}
return ret.chain(function () {
return flatten(result);
}).classic(cb).promise();
} | javascript | {
"resource": ""
} | |
q54697 | train | function () {
var args = argsToArray(arguments);
var cb = isFunction(args[args.length - 1]) ? args.pop() : null;
return this.executeInsert(this.insertSql.apply(this, args)).classic(cb);
} | javascript | {
"resource": ""
} | |
q54698 | train | function (column, cb) {
return this.__aggregateDataset().get(sql.max(column).minus(sql.min(column)), cb);
} | javascript | {
"resource": ""
} | |
q54699 | train | function (args) {
if (!this.__opts.order) {
throw new QueryError("No order specified");
}
var ds = this.reverse();
return ds.first.apply(ds, arguments);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.