repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
remusao/tldts | bin/builders/trie.js | insertInTrie | 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;
... | javascript | 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;
... | [
"function",
"insertInTrie",
"(",
"{",
"parts",
",",
"isIcann",
"}",
",",
"trie",
")",
"{",
"let",
"node",
"=",
"trie",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"part",... | Insert a public suffix rule in the `trie`. | [
"Insert",
"a",
"public",
"suffix",
"rule",
"in",
"the",
"trie",
"."
] | a1036a05fa0dbef44c89fa52ac8eec9af5706be1 | https://github.com/remusao/tldts/blob/a1036a05fa0dbef44c89fa52ac8eec9af5706be1/bin/builders/trie.js#L31-L48 | train |
cBioPortal/clinical-timeline | js/plugins/trimTimeline.js | getXPosAdjustedForKink | 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]) * (tickCoordinate... | javascript | 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]) * (tickCoordinate... | [
"function",
"getXPosAdjustedForKink",
"(",
"pos",
")",
"{",
"var",
"first",
"=",
"clinicalTimelineUtil",
".",
"getLowerBoundIndex",
"(",
"ticksToShow",
",",
"pos",
")",
";",
"var",
"second",
"=",
"first",
"+",
"1",
";",
"if",
"(",
"second",
">",
"ticksToShow... | returns updated x coordinate for the data elements according to th trimmed timeline
@param {int} pos starting time of the clinical timeline element
@return {int} updated x coordinate post-trimming | [
"returns",
"updated",
"x",
"coordinate",
"for",
"the",
"data",
"elements",
"according",
"to",
"th",
"trimmed",
"timeline"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/trimTimeline.js#L181-L189 | train |
cBioPortal/clinical-timeline | js/plugins/trimTimeline.js | clickHandlerKink | 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", xAx... | javascript | 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", xAx... | [
"function",
"clickHandlerKink",
"(",
")",
"{",
"timeline",
".",
"pluginSetOrGetState",
"(",
"\"trimClinicalTimeline\"",
",",
"false",
")",
";",
"//create a bounding box to ease the clicking of axis",
"xAxisBBox",
"=",
"d3",
".",
"select",
"(",
"timeline",
".",
"divId",
... | Handles double clicking of the kinks in trimmed timeline
by extending back the timeline
and also handles coming back to trimmed timeline | [
"Handles",
"double",
"clicking",
"of",
"the",
"kinks",
"in",
"trimmed",
"timeline",
"by",
"extending",
"back",
"the",
"timeline",
"and",
"also",
"handles",
"coming",
"back",
"to",
"trimmed",
"timeline"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/trimTimeline.js#L220-L237 | train |
VikramTiwari/reverse-geocode | lib/reverse-geocode.js | lookup | 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((lo... | javascript | 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((lo... | [
"function",
"lookup",
"(",
"latitude",
",",
"longitude",
",",
"countryCode",
")",
"{",
"let",
"minDistance",
"=",
"Infinity",
"let",
"city",
"=",
"{",
"}",
"// start with inout values",
"const",
"start",
"=",
"{",
"latitude",
",",
"longitude",
"}",
"// iterate... | iterates over locations to find closest location to given input lat-lon values
@param {Number} latitude latitude value
@param {Number} longitude longitude value
@param {String} countryCode Country Code. Should exist in /locations/{countryCode}.json
@return {Object} city data in an object | [
"iterates",
"over",
"locations",
"to",
"find",
"closest",
"location",
"to",
"given",
"input",
"lat",
"-",
"lon",
"values"
] | 0fdc808b52cd62b8d1df54ad6a35a1ef3b6ee550 | https://github.com/VikramTiwari/reverse-geocode/blob/0fdc808b52cd62b8d1df54ad6a35a1ef3b6ee550/lib/reverse-geocode.js#L10-L36 | train |
cBioPortal/clinical-timeline | js/plugins/exportTimeline.js | 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++)
... | javascript | 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++)
... | [
"function",
"(",
")",
"{",
"$",
"(",
"\"#addtrack\"",
")",
".",
"css",
"(",
"\"visibility\"",
",",
"\"hidden\"",
")",
";",
"var",
"element",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'path'",
")",
"[",
"0",
"]",
";",
"element",
".",
"setAttribu... | Exports the clinical-timeline as SVG | [
"Exports",
"the",
"clinical",
"-",
"timeline",
"as",
"SVG"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/exportTimeline.js#L22-L55 | train | |
cBioPortal/clinical-timeline | js/plugins/exportTimeline.js | 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 ;... | javascript | 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 ;... | [
"function",
"(",
"download",
")",
"{",
"$",
"(",
"\"#addtrack\"",
")",
".",
"css",
"(",
"\"visibility\"",
",",
"\"hidden\"",
")",
";",
"var",
"element",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'path'",
")",
"[",
"0",
"]",
";",
"element",
".",... | Exports the clinical-timeline as PNG
@param {boolean} download enable or disable download | [
"Exports",
"the",
"clinical",
"-",
"timeline",
"as",
"PNG"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/exportTimeline.js#L60-L94 | train | |
cBioPortal/clinical-timeline | js/plugins/exportTimeline.js | 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 = documen... | javascript | 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 = documen... | [
"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",
"(",
"$",
... | Exports the clinical-timeline to PDF
by converting the PNG generated by clinicalTimelineExporter.generatePNG to PDF | [
"Exports",
"the",
"clinical",
"-",
"timeline",
"to",
"PDF",
"by",
"converting",
"the",
"PNG",
"generated",
"by",
"clinicalTimelineExporter",
".",
"generatePNG",
"to",
"PDF"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/exportTimeline.js#L99-L115 | train | |
cBioPortal/clinical-timeline | js/plugins/zoom.js | zoomExplanation | 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", "timelineZoomExplana... | javascript | 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", "timelineZoomExplana... | [
"function",
"zoomExplanation",
"(",
"divId",
",",
"svg",
",",
"text",
",",
"visibility",
",",
"pos",
")",
"{",
"d3",
".",
"select",
"(",
"divId",
"+",
"\" svg\"",
")",
".",
"insert",
"(",
"\"text\"",
")",
".",
"attr",
"(",
"\"transform\"",
",",
"\"tran... | adds textual explanation for the present current zoom state
@param {string} divId divId for clinical-timeline
@param {Object} svg clinical-timeline's svg object
@param {string} text explanation's text
@param {string} visibility css property to hide/show the explanation
@param {number} pos ... | [
"adds",
"textual",
"explanation",
"for",
"the",
"present",
"current",
"zoom",
"state"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/zoom.js#L128-L137 | train |
cBioPortal/clinical-timeline | js/plugins/configButton.js | function (pluginId, bool) {
timeline.plugins().forEach(function (element) {
if (pluginId === element.obj.id) {
element.enabled = bool;
}
});
timeline();
} | javascript | function (pluginId, bool) {
timeline.plugins().forEach(function (element) {
if (pluginId === element.obj.id) {
element.enabled = bool;
}
});
timeline();
} | [
"function",
"(",
"pluginId",
",",
"bool",
")",
"{",
"timeline",
".",
"plugins",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"pluginId",
"===",
"element",
".",
"obj",
".",
"id",
")",
"{",
"element",
".",
"enabled",
... | handle the selection or deselection of a plugin in the config button
@param {string} pluginId id of the HTML's checkbox element for the plugin
@param {boolean} bool state of checkbox | [
"handle",
"the",
"selection",
"or",
"deselection",
"of",
"a",
"plugin",
"in",
"the",
"config",
"button"
] | 488c65e09c071f193390d6021ff2689282420a5c | https://github.com/cBioPortal/clinical-timeline/blob/488c65e09c071f193390d6021ff2689282420a5c/js/plugins/configButton.js#L33-L40 | train | |
froala/knockout-froala | src/knockout-froala.js | init | 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... | javascript | 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... | [
"function",
"init",
"(",
"element",
",",
"value",
",",
"bindings",
")",
"{",
"var",
"$el",
"=",
"$",
"(",
"element",
")",
";",
"var",
"model",
"=",
"value",
"(",
")",
";",
"var",
"allBindings",
"=",
"unwrap",
"(",
"bindings",
"(",
")",
")",
";",
... | initiate froala editor, listen to its changes
and updates the underlying observable model
@param {element} element
@param {object} value
@param {object} bindings
@api public | [
"initiate",
"froala",
"editor",
"listen",
"to",
"its",
"changes",
"and",
"updates",
"the",
"underlying",
"observable",
"model"
] | 64d72223b48ca48d2f3257dc95302ce182e90b5f | https://github.com/froala/knockout-froala/blob/64d72223b48ca48d2f3257dc95302ce182e90b5f/src/knockout-froala.js#L21-L54 | train |
froala/knockout-froala | src/knockout-froala.js | function (e, editor) {
if (ko.isWriteableObservable(model)) {
var editorValue = editor.html.get();
var current = model();
if (current !== editorValue) {
model(editorValue);
}
}
} | javascript | function (e, editor) {
if (ko.isWriteableObservable(model)) {
var editorValue = editor.html.get();
var current = model();
if (current !== editorValue) {
model(editorValue);
}
}
} | [
"function",
"(",
"e",
",",
"editor",
")",
"{",
"if",
"(",
"ko",
".",
"isWriteableObservable",
"(",
"model",
")",
")",
"{",
"var",
"editorValue",
"=",
"editor",
".",
"html",
".",
"get",
"(",
")",
";",
"var",
"current",
"=",
"model",
"(",
")",
";",
... | update underlying model whenever editor content changed | [
"update",
"underlying",
"model",
"whenever",
"editor",
"content",
"changed"
] | 64d72223b48ca48d2f3257dc95302ce182e90b5f | https://github.com/froala/knockout-froala/blob/64d72223b48ca48d2f3257dc95302ce182e90b5f/src/knockout-froala.js#L36-L44 | train | |
froala/knockout-froala | src/knockout-froala.js | update | 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( editorVal... | javascript | 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( editorVal... | [
"function",
"update",
"(",
"element",
",",
"value",
")",
"{",
"var",
"$el",
"=",
"$",
"(",
"element",
")",
";",
"var",
"modelValue",
"=",
"unwrap",
"(",
"value",
"(",
")",
")",
";",
"var",
"editorInstance",
"=",
"$el",
".",
"data",
"(",
"'froala.edit... | update froala editor whenever underlying observable model
is updated
@param {element} element
@param {object} value
@api public | [
"update",
"froala",
"editor",
"whenever",
"underlying",
"observable",
"model",
"is",
"updated"
] | 64d72223b48ca48d2f3257dc95302ce182e90b5f | https://github.com/froala/knockout-froala/blob/64d72223b48ca48d2f3257dc95302ce182e90b5f/src/knockout-froala.js#L66-L81 | train |
joe-sky/flarej | dist/js/flarej.js | lazyDo | 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... | javascript | 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... | [
"function",
"lazyDo",
"(",
"fn",
",",
"timeOut",
",",
"doName",
",",
"obj",
")",
"{",
"var",
"sto",
"=",
"null",
";",
"if",
"(",
"!",
"obj",
")",
"{",
"obj",
"=",
"window",
";",
"}",
"if",
"(",
"timeOut",
"==",
"null",
")",
"{",
"timeOut",
"=",... | Lazy to do something | [
"Lazy",
"to",
"do",
"something"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L2873-L2898 | train |
joe-sky/flarej | dist/js/flarej.js | pollDo | 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 ... | javascript | 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 ... | [
"function",
"pollDo",
"(",
"fn",
",",
"timeOut",
",",
"doName",
",",
"obj",
")",
"{",
"var",
"siv",
"=",
"null",
";",
"if",
"(",
"!",
"obj",
")",
"{",
"obj",
"=",
"window",
";",
"}",
"if",
"(",
"timeOut",
"==",
"null",
")",
"{",
"timeOut",
"=",... | Poll to do something | [
"Poll",
"to",
"do",
"something"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L2901-L2928 | train |
joe-sky/flarej | dist/js/flarej.js | on | function on(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).addEventListener(name, fn, useCapture);
} | javascript | function on(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).addEventListener(name, fn, useCapture);
} | [
"function",
"on",
"(",
"name",
",",
"fn",
",",
"elem",
")",
"{",
"var",
"useCapture",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"false",
";",
"return",
"("... | Add dom event | [
"Add",
"dom",
"event"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L4973-L4977 | train |
joe-sky/flarej | dist/js/flarej.js | off | function off(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).removeEventListener(name, fn, useCapture);
} | javascript | function off(name, fn, elem) {
var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
return (elem || doc).removeEventListener(name, fn, useCapture);
} | [
"function",
"off",
"(",
"name",
",",
"fn",
",",
"elem",
")",
"{",
"var",
"useCapture",
"=",
"arguments",
".",
"length",
">",
"3",
"&&",
"arguments",
"[",
"3",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"3",
"]",
":",
"false",
";",
"return",
"(... | Remove dom event | [
"Remove",
"dom",
"event"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L4980-L4984 | train |
joe-sky/flarej | dist/js/flarej.js | pageWidth | 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 | function pageWidth() {
return win.innerWidth != null ? win.innerWidth : doc.documentElement && doc.documentElement.clientWidth != null ? doc.documentElement.clientWidth : doc.body != null ? doc.body.clientWidth : null;
} | [
"function",
"pageWidth",
"(",
")",
"{",
"return",
"win",
".",
"innerWidth",
"!=",
"null",
"?",
"win",
".",
"innerWidth",
":",
"doc",
".",
"documentElement",
"&&",
"doc",
".",
"documentElement",
".",
"clientWidth",
"!=",
"null",
"?",
"doc",
".",
"documentEl... | Get current width of page | [
"Get",
"current",
"width",
"of",
"page"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L6864-L6866 | train |
joe-sky/flarej | dist/js/flarej.js | pageHeight | 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 | function pageHeight() {
return win.innerHeight != null ? win.innerHeight : doc.documentElement && doc.documentElement.clientHeight != null ? doc.documentElement.clientHeight : doc.body != null ? doc.body.clientHeight : null;
} | [
"function",
"pageHeight",
"(",
")",
"{",
"return",
"win",
".",
"innerHeight",
"!=",
"null",
"?",
"win",
".",
"innerHeight",
":",
"doc",
".",
"documentElement",
"&&",
"doc",
".",
"documentElement",
".",
"clientHeight",
"!=",
"null",
"?",
"doc",
".",
"docume... | Get current height of page | [
"Get",
"current",
"height",
"of",
"page"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L6872-L6874 | train |
joe-sky/flarej | dist/js/flarej.js | clone | 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: functi... | javascript | 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: functi... | [
"function",
"clone",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"foundFirst",
"&&",
"selectedKeys",
".",
"indexOf",
"(",
"item",
".",
"key",
")",
"!==",
"-",
"1",
"||",
"!",
"foundFirst",
"&&",
"!",
"selectedKeys",
".",
"length",
"&&",
"firstActiveValue",
... | set firstActiveItem via cloning menus for scroll into view | [
"set",
"firstActiveItem",
"via",
"cloning",
"menus",
"for",
"scroll",
"into",
"view"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L33036-L33046 | train |
joe-sky/flarej | dist/js/flarej.js | matches | 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;
... | javascript | 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;
... | [
"function",
"matches",
"(",
"elem",
",",
"selector",
")",
"{",
"// Vendor-specific implementations of `Element.prototype.matches()`.",
"var",
"proto",
"=",
"window",
".",
"Element",
".",
"prototype",
";",
"var",
"nativeMatches",
"=",
"proto",
".",
"matches",
"||",
"... | Determine if a DOM element matches a CSS selector
@param {Element} elem
@param {String} selector
@return {Boolean}
@api public | [
"Determine",
"if",
"a",
"DOM",
"element",
"matches",
"a",
"CSS",
"selector"
] | d1dd8bf8e34f9110869e4ce3f40d8f93a8030168 | https://github.com/joe-sky/flarej/blob/d1dd8bf8e34f9110869e4ce3f40d8f93a8030168/dist/js/flarej.js#L33983-L34014 | train |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | insert | 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) : targe... | javascript | 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) : targe... | [
"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... | this insert method is intense | [
"this",
"insert",
"method",
"is",
"intense"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L329-L356 | train |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | each | function each(a, fn) {
var i = 0, l = a.length
for (; i < l; i++) fn.call(null, a[i])
} | javascript | function each(a, fn) {
var i = 0, l = a.length
for (; i < l; i++) fn.call(null, a[i])
} | [
"function",
"each",
"(",
"a",
",",
"fn",
")",
"{",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
"for",
"(",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"fn",
".",
"call",
"(",
"null",
",",
"a",
"[",
"i",
"]",
")",
"}"
] | not quite as fast as inline loops in older browsers so don't use liberally | [
"not",
"quite",
"as",
"fast",
"as",
"inline",
"loops",
"in",
"older",
"browsers",
"so",
"don",
"t",
"use",
"liberally"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L1164-L1167 | train |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | _qwery | 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 = (token... | javascript | 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 = (token... | [
"function",
"_qwery",
"(",
"selector",
",",
"_root",
")",
"{",
"var",
"r",
"=",
"[",
"]",
",",
"ret",
"=",
"[",
"]",
",",
"i",
",",
"l",
",",
"m",
",",
"token",
",",
"tag",
",",
"els",
",",
"intr",
",",
"item",
",",
"root",
"=",
"_root",
",... | given a selector, first check for simple cases then collect all base candidate matches and filter | [
"given",
"a",
"selector",
"first",
"check",
"for",
"simple",
"cases",
"then",
"collect",
"all",
"base",
"candidate",
"matches",
"and",
"filter"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L1243-L1273 | train |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | crawl | 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 | 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
}
}
} | [
"function",
"crawl",
"(",
"e",
",",
"i",
",",
"p",
")",
"{",
"while",
"(",
"p",
"=",
"walker",
"[",
"dividedTokens",
"[",
"i",
"]",
"]",
"(",
"p",
",",
"e",
")",
")",
"{",
"if",
"(",
"isNode",
"(",
"p",
")",
"&&",
"(",
"interpret",
".",
"ap... | recursively work backwards through the tokens and up the dom, covering all options | [
"recursively",
"work",
"backwards",
"through",
"the",
"tokens",
"and",
"up",
"the",
"dom",
"covering",
"all",
"options"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L1296-L1304 | train |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | 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--;) {
... | javascript | 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--;) {
... | [
"function",
"(",
"checkNamespaces",
")",
"{",
"var",
"i",
",",
"j",
"if",
"(",
"!",
"checkNamespaces",
")",
"return",
"true",
"if",
"(",
"!",
"this",
".",
"namespaces",
")",
"return",
"false",
"for",
"(",
"i",
"=",
"checkNamespaces",
".",
"length",
";"... | given a list of namespaces, is our entry in any of them? | [
"given",
"a",
"list",
"of",
"namespaces",
"is",
"our",
"entry",
"in",
"any",
"of",
"them?"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L1730-L1743 | train | |
afeld/backbone-nested | vendor/DocumentUp/documentup.js | 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 | 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()
} | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"entries",
"=",
"registry",
".",
"entries",
"(",
")",
"for",
"(",
"i",
"in",
"entries",
")",
"{",
"if",
"(",
"entries",
"[",
"i",
"]",
".",
"type",
"&&",
"entries",
"[",
"i",
"]",
".",
"type",
"!==",
... | for IE, clean up on unload to avoid leaks | [
"for",
"IE",
"clean",
"up",
"on",
"unload",
"to",
"avoid",
"leaks"
] | 7d69a1178056f99c69be4c381e4e3bdf016739ce | https://github.com/afeld/backbone-nested/blob/7d69a1178056f99c69be4c381e4e3bdf016739ce/vendor/DocumentUp/documentup.js#L2032-L2040 | train | |
C2FO/patio | lib/plugins/columnMapper.js | 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);
... | javascript | 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);
... | [
"function",
"(",
"name",
",",
"table",
",",
"condition",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"name",
")",
"{",
"name",
"=",
"sql",
".",
"stringToIdentifier",
"(",
"name",
")",
";",
"if",
"(",
"table",
"&&",... | Add a mapped column from another table. This is useful if there columns on
another table but you do not want to load the association every time.
For example assume we have an employee and works table. Well we might want the salary from the works table,
but do not want to add it to the employee table.
<b>NOTE:</b> ma... | [
"Add",
"a",
"mapped",
"column",
"from",
"another",
"table",
".",
"This",
"is",
"useful",
"if",
"there",
"columns",
"on",
"another",
"table",
"but",
"you",
"do",
"not",
"want",
"to",
"load",
"the",
"association",
"every",
"time",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/columnMapper.js#L113-L125 | train | |
C2FO/patio | lib/adapters/postgres.js | 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 = ... | javascript | 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 = ... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__serverVersion",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"__serverVersion",
"=",
"this",
".",
"get",
"(",
"identifier",
"(",
"\"version\"",
")",
".",
"sqlFunction",
")",
".",
"... | Get version of postgres server, used for determined capabilities. | [
"Get",
"version",
"of",
"postgres",
"server",
"used",
"for",
"determined",
"capabilities",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/postgres.js#L679-L690 | train | |
C2FO/patio | lib/adapters/postgres.js | 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")});
... | javascript | 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")});
... | [
"function",
"(",
"type",
",",
"opts",
",",
"cb",
")",
"{",
"var",
"ret",
";",
"var",
"ds",
"=",
"this",
".",
"metadataDataset",
".",
"from",
"(",
"\"pg_class\"",
")",
".",
"filter",
"(",
"{",
"relkind",
":",
"type",
"}",
")",
".",
"select",
"(",
... | Backbone of the tables and views support. | [
"Backbone",
"of",
"the",
"tables",
"and",
"views",
"support",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/postgres.js#L858-L874 | train | |
C2FO/patio | lib/adapters/postgres.js | 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 | 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';
}
... | [
"function",
"(",
"column",
")",
"{",
"if",
"(",
"column",
".",
"fixed",
")",
"{",
"return",
"[",
"\"char(\"",
",",
"column",
".",
"size",
"||",
"255",
",",
"\")\"",
"]",
".",
"join",
"(",
"\"\"",
")",
";",
"}",
"else",
"if",
"(",
"column",
".",
... | PostgreSQL prefers the text datatype. If a fixed size is requested, the char type is used. If the text type is specifically disallowed or there is a size specified, use the varchar type. Otherwise use the type type. | [
"PostgreSQL",
"prefers",
"the",
"text",
"datatype",
".",
"If",
"a",
"fixed",
"size",
"is",
"requested",
"the",
"char",
"type",
"is",
"used",
".",
"If",
"the",
"text",
"type",
"is",
"specifically",
"disallowed",
"or",
"there",
"is",
"a",
"size",
"specified"... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/postgres.js#L1005-L1014 | train | |
C2FO/patio | lib/associations/_Association.js | 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._setAssociati... | javascript | 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._setAssociati... | [
"function",
"(",
"parent",
")",
"{",
"var",
"options",
"=",
"this",
".",
"__opts",
"||",
"{",
"}",
";",
"var",
"ds",
",",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"isUndefined",
"(",
"(",
"ds",
"=",
"options",
".",
"dataset",
")",
")",
"&&",
"... | Filters our associated dataset to load our association.
@return {Dataset} the dataset with all filters applied. | [
"Filters",
"our",
"associated",
"dataset",
"to",
"load",
"our",
"association",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/associations/_Association.js#L238-L269 | train | |
C2FO/patio | lib/associations/_Association.js | 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 {
... | javascript | 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 {
... | [
"function",
"(",
"model",
")",
"{",
"//if we have them return them;",
"if",
"(",
"this",
".",
"associationLoaded",
"(",
"model",
")",
")",
"{",
"var",
"assoc",
"=",
"this",
".",
"getAssociation",
"(",
"model",
")",
";",
"return",
"this",
".",
"isEager",
"(... | Alias used to explicitly get an association on a model.
@param {_Association} self reference to the Association that is being called. | [
"Alias",
"used",
"to",
"explicitly",
"get",
"an",
"association",
"on",
"a",
"model",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/associations/_Association.js#L413-L423 | train | |
C2FO/patio | lib/associations/_Association.js | 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["__def... | javascript | 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["__def... | [
"function",
"(",
"parent",
",",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"parent",
"=",
"parent",
";",
"var",
"parentProto",
"=",
"parent",
".",
"prototype",
";",
"parentProto",
"[",
"\"__... | Method to inject functionality into a model. This method alters the model
to prepare it for associations, and initializes all required middleware calls
to fulfill requirements needed to loaded the associations.
@param {Model} parent the model that is having an associtaion set on it.
@param {String} name the name of th... | [
"Method",
"to",
"inject",
"functionality",
"into",
"a",
"model",
".",
"This",
"method",
"alters",
"the",
"model",
"to",
"prepare",
"it",
"for",
"associations",
"and",
"initializes",
"all",
"required",
"middleware",
"calls",
"to",
"fulfill",
"requirements",
"need... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/associations/_Association.js#L445-L472 | train | |
C2FO/patio | lib/plugins/inheritance.js | 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 | 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();
} | [
"function",
"(",
")",
"{",
"var",
"q",
"=",
"this",
".",
"_getPrimaryKeyQuery",
"(",
")",
";",
"return",
"new",
"PromiseList",
"(",
"this",
".",
"_static",
".",
"__ctiTables",
".",
"slice",
"(",
")",
".",
"reverse",
"(",
")",
".",
"map",
"(",
"functi... | Delete the row from all backing tables, starting from the most recent table and going through all superclasses. | [
"Delete",
"the",
"row",
"from",
"all",
"backing",
"tables",
"starting",
"from",
"the",
"most",
"recent",
"table",
"and",
"going",
"through",
"all",
"superclasses",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/inheritance.js#L127-L132 | train | |
C2FO/patio | lib/plugins/inheritance.js | 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... | javascript | 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... | [
"function",
"(",
")",
"{",
"var",
"Self",
"=",
"this",
".",
"_static",
",",
"ret",
";",
"if",
"(",
"Self",
"===",
"Self",
".",
"__ctiBaseModel",
")",
"{",
"ret",
"=",
"this",
".",
"_super",
"(",
"arguments",
")",
";",
"}",
"else",
"{",
"var",
"pk... | Save each column according to the columns in each table | [
"Save",
"each",
"column",
"according",
"to",
"the",
"columns",
"in",
"each",
"table"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/inheritance.js#L135-L165 | train | |
C2FO/patio | lib/plugins/inheritance.js | 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... | javascript | 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... | [
"function",
"(",
")",
"{",
"var",
"q",
"=",
"this",
".",
"_getPrimaryKeyQuery",
"(",
")",
",",
"changed",
"=",
"this",
".",
"__changed",
";",
"var",
"modelStatic",
"=",
"this",
".",
"_static",
",",
"ctiColumns",
"=",
"modelStatic",
".",
"__ctiColumns",
"... | update each column according to the columns in each table | [
"update",
"each",
"column",
"according",
"to",
"the",
"columns",
"in",
"each",
"table"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/inheritance.js#L168-L187 | train | |
C2FO/patio | lib/dataset/sql.js | 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);
}, ... | javascript | 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);
}, ... | [
"function",
"(",
"tableAlias",
")",
"{",
"tableAlias",
"=",
"this",
".",
"_toTableName",
"(",
"tableAlias",
")",
";",
"var",
"usedAliases",
"=",
"[",
"]",
",",
"from",
",",
"join",
";",
"if",
"(",
"(",
"from",
"=",
"this",
".",
"__opts",
".",
"from",... | Creates a unique table alias that hasn't already been used in this dataset.
@example
DB.from("table").unusedTableAlias("t");
//=> "t"
DB.from("table").unusedTableAlias("table");
//=> "table0"
DB.from("table", "table0"]).unusedTableAlias("table");
//=> "table1"
@param {String|patio.sql.Identifier} tableAlias the ta... | [
"Creates",
"a",
"unique",
"table",
"alias",
"that",
"hasn",
"t",
"already",
"been",
"used",
"in",
"this",
"dataset",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L358-L382 | train | |
C2FO/patio | lib/dataset/sql.js | 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))... | javascript | 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))... | [
"function",
"(",
"v",
")",
"{",
"if",
"(",
"isInstanceOf",
"(",
"v",
",",
"Json",
",",
"JsonArray",
")",
")",
"{",
"return",
"this",
".",
"_literalJson",
"(",
"v",
")",
";",
"}",
"else",
"if",
"(",
"isInstanceOf",
"(",
"v",
",",
"LiteralString",
")... | Returns a literal representation of a value to be used as part
of an SQL expression.
@example
DB.from("items").literal("abc'def\\") //=> "'abc''def\\\\'"
DB.from("items").literal("items__id") //=> "items.id"
DB.from("items").literal([1, 2, 3]) //=> "(1, 2, 3)"
DB.from("items").literal(DB.from("items")) //=> "(SELECT ... | [
"Returns",
"a",
"literal",
"representation",
"of",
"a",
"value",
"to",
"be",
"used",
"as",
"part",
"of",
"an",
"SQL",
"expression",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L401-L435 | train | |
C2FO/patio | lib/dataset/sql.js | 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)... | javascript | 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)... | [
"function",
"(",
"name",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"isString",
"(",
"name",
")",
")",
"{",
"var",
"parts",
"=",
"this",
".",
"_splitString",
"(",
"name",
")",
";",
"var",
"schema",
"=",
"parts",
"[",
"0",
"]",
",",
"table",
"=",
"... | Returns a string that is the name of the table.
@throws {patio.QueryError} If the name is not a String {@link patio.sql.Identifier},
{@link patio.sql.QualifiedIdentifier} or {@link patio.sql.AliasedExpression}.
@param {String|patio.sql.Identifier|patio.sql.QualifiedIdentifier|patio.sql.AliasedExpression} name
the obj... | [
"Returns",
"a",
"string",
"that",
"is",
"the",
"name",
"of",
"the",
"table",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L512-L528 | train | |
C2FO/patio | lib/dataset/sql.js | 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]()... | javascript | 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]()... | [
"function",
"(",
"type",
")",
"{",
"var",
"sql",
"=",
"[",
"(",
"\"\"",
"+",
"type",
")",
".",
"toUpperCase",
"(",
")",
"]",
";",
"try",
"{",
"this",
".",
"_static",
"[",
"sql",
"+",
"\"_CLAUSE_METHODS\"",
"]",
".",
"forEach",
"(",
"function",
"(",... | Prepares an SQL statement by calling all clause methods for the given statement type. | [
"Prepares",
"an",
"SQL",
"statement",
"by",
"calling",
"all",
"clause",
"methods",
"for",
"the",
"given",
"statement",
"type",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L597-L614 | train | |
C2FO/patio | lib/dataset/sql.js | 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) + ")";
... | javascript | 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) + ")";
... | [
"function",
"(",
"sql",
")",
"{",
"var",
"columns",
"=",
"this",
".",
"__opts",
".",
"columns",
",",
"ret",
"=",
"\"\"",
";",
"if",
"(",
"columns",
"&&",
"columns",
".",
"length",
")",
"{",
"ret",
"=",
"\" (\"",
"+",
"columns",
".",
"map",
"(",
"... | SQL fragment specifying the columns to insert into | [
"SQL",
"fragment",
"specifying",
"the",
"columns",
"to",
"insert",
"into"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L623-L632 | train | |
C2FO/patio | lib/dataset/sql.js | 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)... | javascript | 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)... | [
"function",
"(",
")",
"{",
"var",
"values",
"=",
"this",
".",
"__opts",
".",
"values",
",",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"isArray",
"(",
"values",
")",
")",
"{",
"ret",
".",
"push",
"(",
"values",
".",
"length",
"===",
"0",
"?",
"\" DE... | SQL fragment specifying the values to insert. | [
"SQL",
"fragment",
"specifying",
"the",
"values",
"to",
"insert",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L635-L647 | train | |
C2FO/patio | lib/dataset/sql.js | 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) {
... | javascript | 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) {
... | [
"function",
"(",
"source",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"source",
")",
")",
"{",
"source",
"=",
"[",
"source",
"]",
";",
"}",
"if",
"(",
"!",
"source",
"||",
"!",
"source",
".",
"length",
")",
"{",
"throw",
"new",
"Qu... | Converts an array of source names into into a comma separated list. | [
"Converts",
"an",
"array",
"of",
"source",
"names",
"into",
"into",
"a",
"comma",
"separated",
"list",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/sql.js#L1503-L1514 | train | |
C2FO/patio | example/readme-example/migration/1398228686331.createInitialTables.js | 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);
... | javascript | 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);
... | [
"function",
"(",
"db",
")",
"{",
"//create a table called state;",
"return",
"db",
".",
"createTable",
"(",
"\"state\"",
",",
"function",
"(",
")",
"{",
"this",
".",
"primaryKey",
"(",
"\"id\"",
")",
";",
"this",
".",
"name",
"(",
"String",
")",
";",
"th... | up is called when you migrate your database up | [
"up",
"is",
"called",
"when",
"you",
"migrate",
"your",
"database",
"up"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/example/readme-example/migration/1398228686331.createInitialTables.js#L3-L24 | train | |
C2FO/patio | lib/migration.js | 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 | 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;
... | [
"function",
"(",
"db",
",",
"directory",
",",
"opts",
")",
"{",
"this",
".",
"db",
"=",
"db",
";",
"this",
".",
"directory",
"=",
"directory",
";",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"table",
"=",
"opts",
".",
"table",
"||",
... | Abstract Migrator class. This class should be be instantiated directly.
@constructs
@param {patio.Database} db the database to migrate
@param {String} directory directory that the migration files reside in
@param {Object} [opts={}] optional parameters.
@param {String} [opts.column] the column in the table that version... | [
"Abstract",
"Migrator",
"class",
".",
"This",
"class",
"should",
"be",
"be",
"instantiated",
"directly",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/migration.js#L43-L50 | train | |
C2FO/patio | lib/migration.js | 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.__schem... | javascript | 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.__schem... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__schemaDataset",
")",
"{",
"var",
"ds",
"=",
"this",
".",
"db",
".",
"from",
"(",
"this",
".",
"table",
")",
",",
"self",
"=",
"this",
";",
"return",
"this",
".",
"__createTable",
"(",
")"... | Returns the dataset for the schema_migrations table. If no such table exists, it is automatically created. | [
"Returns",
"the",
"dataset",
"for",
"the",
"schema_migrations",
"table",
".",
"If",
"no",
"such",
"table",
"exists",
"it",
"is",
"automatically",
"created",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/migration.js#L485-L494 | train | |
C2FO/patio | lib/sql.js | function (obj) {
return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) {
return isArray(i) && i.length === 2;
}));
} | javascript | function (obj) {
return isHash(obj) || (isArray(obj) && obj.length && obj.every(function (i) {
return isArray(i) && i.length === 2;
}));
} | [
"function",
"(",
"obj",
")",
"{",
"return",
"isHash",
"(",
"obj",
")",
"||",
"(",
"isArray",
"(",
"obj",
")",
"&&",
"obj",
".",
"length",
"&&",
"obj",
".",
"every",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"isArray",
"(",
"i",
")",
"&&",
... | Helper to determine if something is a condition specifier. Returns true if the object
is a Hash or is an array of two element arrays.
@example
Expression.isConditionSpecifier({a : "b"}); //=> true
Expression.isConditionSpecifier("a"); //=> false
Expression.isConditionSpecifier([["a", "b"], ["c", "d"]]); //=> true
Expr... | [
"Helper",
"to",
"determine",
"if",
"something",
"is",
"a",
"condition",
"specifier",
".",
"Returns",
"true",
"if",
"the",
"object",
"is",
"a",
"Hash",
"or",
"is",
"an",
"array",
"of",
"two",
"element",
"arrays",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/sql.js#L1397-L1401 | train | |
C2FO/patio | lib/sql.js | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.castSql(this.expr, this.type);
} | javascript | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.castSql(this.expr, this.type);
} | [
"function",
"(",
"ds",
")",
"{",
"!",
"Dataset",
"&&",
"(",
"Dataset",
"=",
"require",
"(",
"\"./dataset\"",
")",
")",
";",
"ds",
"=",
"ds",
"||",
"new",
"Dataset",
"(",
")",
";",
"return",
"ds",
".",
"castSql",
"(",
"this",
".",
"expr",
",",
"th... | Converts the cast expression to a string
@param {patio.Dataset} [ds] dataset used to created the SQL fragment, if
the dataset is ommited then the default {@link patio.Dataset} implementation is used.
@return String the SQL cast expression fragment. | [
"Converts",
"the",
"cast",
"expression",
"to",
"a",
"string"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/sql.js#L1549-L1553 | train | |
C2FO/patio | lib/sql.js | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.complexExpressionSql(this.op, this.args);
} | javascript | function (ds) {
!Dataset && (Dataset = require("./dataset"));
ds = ds || new Dataset();
return ds.complexExpressionSql(this.op, this.args);
} | [
"function",
"(",
"ds",
")",
"{",
"!",
"Dataset",
"&&",
"(",
"Dataset",
"=",
"require",
"(",
"\"./dataset\"",
")",
")",
";",
"ds",
"=",
"ds",
"||",
"new",
"Dataset",
"(",
")",
";",
"return",
"ds",
".",
"complexExpressionSql",
"(",
"this",
".",
"op",
... | Converts the ComplexExpression to a string.
@param {patio.Dataset} [ds] dataset used to created the SQL fragment, if
the dataset is ommited then the default {@link patio.Dataset} implementation is used.
@return String the SQL version of the {@link patio.sql.ComplexExpression}. | [
"Converts",
"the",
"ComplexExpression",
"to",
"a",
"string",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/sql.js#L1674-L1678 | train | |
C2FO/patio | lib/dataset/query.js | 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;
})... | javascript | 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;
})... | [
"function",
"(",
"args",
")",
"{",
"args",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"if",
"(",
"args",
".",
"length",
"&&",
"!",
"this",
".",
"supportsDistinctOn",
")",
"{",
"throw",
"new",
"QueryError",
"(",
"\"DISTICT ON is not supported\"",
")",
... | Returns a copy of the dataset with the SQL DISTINCT clause.
The DISTINCT clause is used to remove duplicate rows from the
output. If arguments are provided, uses a DISTINCT ON clause,
in which case it will only be distinct on those columns, instead
of all returned columns.
@example
DB.from("items").distinct().sqll
/... | [
"Returns",
"a",
"copy",
"of",
"the",
"dataset",
"with",
"the",
"SQL",
"DISTINCT",
"clause",
".",
"The",
"DISTINCT",
"clause",
"is",
"used",
"to",
"remove",
"duplicate",
"rows",
"from",
"the",
"output",
".",
"If",
"arguments",
"are",
"provided",
"uses",
"a"... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L327-L336 | train | |
C2FO/patio | lib/dataset/query.js | function(includeDatasets, fromModel) {
var ds = this.mergeOptions({}),
originalRowCb = ds.rowCb;
if(!ds.__opts._eagerAssoc) {
ds.__opts._eagerAssoc = includeDatasets;
ds.rowCb = function (topLevelResults) {
function toObject(t... | javascript | function(includeDatasets, fromModel) {
var ds = this.mergeOptions({}),
originalRowCb = ds.rowCb;
if(!ds.__opts._eagerAssoc) {
ds.__opts._eagerAssoc = includeDatasets;
ds.rowCb = function (topLevelResults) {
function toObject(t... | [
"function",
"(",
"includeDatasets",
",",
"fromModel",
")",
"{",
"var",
"ds",
"=",
"this",
".",
"mergeOptions",
"(",
"{",
"}",
")",
",",
"originalRowCb",
"=",
"ds",
".",
"rowCb",
";",
"if",
"(",
"!",
"ds",
".",
"__opts",
".",
"_eagerAssoc",
")",
"{",
... | Allows the loading of another query and combining them in one patio command.
Queries can be related or completely unrelated.
All data comes back as JSON NOT Patio models.
@example
DB.from('company').filter({name: 'Amazon'})
.eager({
// company from parent query is passed in and usable in the eager query.
leader: (com... | [
"Allows",
"the",
"loading",
"of",
"another",
"query",
"and",
"combining",
"them",
"in",
"one",
"patio",
"command",
".",
"Queries",
"can",
"be",
"related",
"or",
"completely",
"unrelated",
".",
"All",
"data",
"comes",
"back",
"as",
"JSON",
"NOT",
"Patio",
"... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L391-L446 | train | |
C2FO/patio | lib/dataset/query.js | function (args, cb) {
args = [this.__opts["having"] ? "having" : "where"].concat(argsToArray(arguments));
return this._filter.apply(this, args);
} | javascript | function (args, cb) {
args = [this.__opts["having"] ? "having" : "where"].concat(argsToArray(arguments));
return this._filter.apply(this, args);
} | [
"function",
"(",
"args",
",",
"cb",
")",
"{",
"args",
"=",
"[",
"this",
".",
"__opts",
"[",
"\"having\"",
"]",
"?",
"\"having\"",
":",
"\"where\"",
"]",
".",
"concat",
"(",
"argsToArray",
"(",
"arguments",
")",
")",
";",
"return",
"this",
".",
"_filt... | Returns a copy of the dataset with the given conditions applied to it.
If the query already has a HAVING clause, then the conditions are applied to the
HAVING clause otherwise they are applied to the WHERE clause.
@example
DB.from("items").filter({id : 3}).sql;
//=> SELECT * FROM items WHERE (id = 3)
DB.from("items"... | [
"Returns",
"a",
"copy",
"of",
"the",
"dataset",
"with",
"the",
"given",
"conditions",
"applied",
"to",
"it",
".",
"If",
"the",
"query",
"already",
"has",
"a",
"HAVING",
"clause",
"then",
"the",
"conditions",
"are",
"applied",
"to",
"the",
"HAVING",
"clause... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L583-L586 | train | |
C2FO/patio | lib/dataset/query.js | 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;
... | javascript | 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;
... | [
"function",
"(",
"opts",
")",
"{",
"opts",
"=",
"isUndefined",
"(",
"opts",
")",
"?",
"{",
"}",
":",
"opts",
";",
"var",
"fs",
"=",
"{",
"}",
";",
"var",
"nonSqlOptions",
"=",
"this",
".",
"_static",
".",
"NON_SQL_OPTIONS",
";",
"Object",
".",
"key... | Returns a dataset selecting from the current dataset.
Supplying the alias option controls the alias of the result.
@example
ds = DB.from("items").order("name").select("id", "name")
//=> SELECT id,name FROM items ORDER BY name
ds.fromSelf().sql;
//=> SELECT * FROM (SELECT id, name FROM items ORDER BY name) AS t1
ds.... | [
"Returns",
"a",
"dataset",
"selecting",
"from",
"the",
"current",
"dataset",
".",
"Supplying",
"the",
"alias",
"option",
"controls",
"the",
"alias",
"of",
"the",
"result",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L677-L687 | train | |
C2FO/patio | lib/dataset/query.js | 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 | 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]));
... | [
"function",
"(",
"columns",
")",
"{",
"columns",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"var",
"group",
"=",
"this",
".",
"group",
".",
"apply",
"(",
"this",
",",
"columns",
".",
"map",
"(",
"function",
"(",
"c",
")",
"{",
"return",
"this",
... | Returns a dataset grouped by the given column with count by group.
Column aliases may be supplied, and will be included in the select clause.
@example
DB.from("items").groupAndCount("name").all()
//=> SELECT name, count(*) AS count FROM items GROUP BY name
//=> [{name : 'a', count : 1}, ...]
DB.from("items").groupAn... | [
"Returns",
"a",
"dataset",
"grouped",
"by",
"the",
"given",
"column",
"with",
"count",
"by",
"group",
".",
"Column",
"aliases",
"may",
"be",
"supplied",
"and",
"will",
"be",
"included",
"in",
"the",
"select",
"clause",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L804-L811 | train | |
C2FO/patio | lib/dataset/query.js | 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.suppo... | javascript | 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.suppo... | [
"function",
"(",
"dataset",
",",
"opts",
")",
"{",
"opts",
"=",
"isUndefined",
"(",
"opts",
")",
"?",
"{",
"}",
":",
"opts",
";",
"if",
"(",
"!",
"isHash",
"(",
"opts",
")",
")",
"{",
"opts",
"=",
"{",
"all",
":",
"opts",
"}",
";",
"}",
"if",... | Adds an INTERSECT clause using a second dataset object.
An INTERSECT compound dataset returns all rows in both the current dataset
and the given dataset.
@example
DB.from("items").intersect(DB.from("other_items")).sql;
//=> SELECT * FROM (SELECT * FROM items INTERSECT SELECT * FROM other_items) AS t1
DB.from("items"... | [
"Adds",
"an",
"INTERSECT",
"clause",
"using",
"a",
"second",
"dataset",
"object",
".",
"An",
"INTERSECT",
"compound",
"dataset",
"returns",
"all",
"rows",
"in",
"both",
"the",
"current",
"dataset",
"and",
"the",
"given",
"dataset",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L854-L865 | train | |
C2FO/patio | lib/dataset/query.js | 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);
... | javascript | 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);
... | [
"function",
"(",
")",
"{",
"var",
"having",
"=",
"this",
".",
"__opts",
".",
"having",
",",
"where",
"=",
"this",
".",
"__opts",
".",
"where",
";",
"if",
"(",
"!",
"(",
"having",
"||",
"where",
")",
")",
"{",
"throw",
"new",
"QueryError",
"(",
"\... | Inverts the current filter.
@example
DB.from("items").filter({category : 'software'}).invert()
//=> SELECT * FROM items WHERE (category != 'software')
@example
DB.from("items").filter({category : 'software', id : 3}).invert()
//=> SELECT * FROM items WHERE ((category != 'software') OR (id != 3))
@return {patio.Datas... | [
"Inverts",
"the",
"current",
"filter",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L880-L893 | train | |
C2FO/patio | lib/dataset/query.js | 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 (isStrin... | javascript | 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 (isStrin... | [
"function",
"(",
"limit",
",",
"offset",
")",
"{",
"if",
"(",
"this",
".",
"__opts",
".",
"sql",
")",
"{",
"return",
"this",
".",
"fromSelf",
"(",
")",
".",
"limit",
"(",
"limit",
",",
"offset",
")",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
... | If given an integer, the dataset will contain only the first l results.
If a second argument is given, it is used as an offset. To use
an offset without a limit, pass null as the first argument.
@example
DB.from("items").limit(10)
//=> SELECT * FROM items LIMIT 10
DB.from("items").limit(10, 20)
//=> SELECT * FROM ite... | [
"If",
"given",
"an",
"integer",
"the",
"dataset",
"will",
"contain",
"only",
"the",
"first",
"l",
"results",
".",
"If",
"a",
"second",
"argument",
"is",
"given",
"it",
"is",
"used",
"as",
"an",
"offset",
".",
"To",
"use",
"an",
"offset",
"without",
"a"... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L1124-L1150 | train | |
C2FO/patio | lib/dataset/query.js | 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);
... | javascript | 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);
... | [
"function",
"(",
"table",
")",
"{",
"var",
"o",
"=",
"this",
".",
"__opts",
";",
"if",
"(",
"o",
".",
"sql",
")",
"{",
"return",
"this",
".",
"mergeOptions",
"(",
")",
";",
"}",
"var",
"h",
"=",
"{",
"}",
";",
"array",
".",
"intersect",
"(",
... | Return a copy of the dataset with unqualified identifiers in the
SELECT, WHERE, GROUP, HAVING, and ORDER clauses qualified by the
given table. If no columns are currently selected, select all
columns of the given table.
@example
DB.from("items").filter({id : 1}).qualifyTo("i");
//=> SELECT i.* FROM items WHERE (i.id =... | [
"Return",
"a",
"copy",
"of",
"the",
"dataset",
"with",
"unqualified",
"identifiers",
"in",
"the",
"SELECT",
"WHERE",
"GROUP",
"HAVING",
"and",
"ORDER",
"clauses",
"qualified",
"by",
"the",
"given",
"table",
".",
"If",
"no",
"columns",
"are",
"currently",
"se... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L1653-L1666 | train | |
C2FO/patio | lib/dataset/query.js | function (args) {
args = argsToArray(arguments);
return this.order.apply(this, this._invertOrder(args.length ? args : this.__opts.order));
} | javascript | function (args) {
args = argsToArray(arguments);
return this.order.apply(this, this._invertOrder(args.length ? args : this.__opts.order));
} | [
"function",
"(",
"args",
")",
"{",
"args",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"return",
"this",
".",
"order",
".",
"apply",
"(",
"this",
",",
"this",
".",
"_invertOrder",
"(",
"args",
".",
"length",
"?",
"args",
":",
"this",
".",
"__opts... | Returns a copy of the dataset with the order reversed. If no order is
given, the existing order is inverted.
@example
DB.from("items").reverse("id");
//=> SELECT * FROM items ORDER BY id DESC
DB.from("items").order("id").reverse();
//=> SELECT * FROM items ORDER BY id DESC
DB.from("items").order("id").reverse(sql.id... | [
"Returns",
"a",
"copy",
"of",
"the",
"dataset",
"with",
"the",
"order",
"reversed",
".",
"If",
"no",
"order",
"is",
"given",
"the",
"existing",
"order",
"is",
"inverted",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L1710-L1713 | train | |
C2FO/patio | lib/dataset/query.js | function (cols) {
var ret;
if (!this.hasSelectSource) {
ret = this.select.apply(this, arguments);
} else {
ret = this.mergeOptions();
}
return ret;
} | javascript | function (cols) {
var ret;
if (!this.hasSelectSource) {
ret = this.select.apply(this, arguments);
} else {
ret = this.mergeOptions();
}
return ret;
} | [
"function",
"(",
"cols",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"!",
"this",
".",
"hasSelectSource",
")",
"{",
"ret",
"=",
"this",
".",
"select",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"else",
"{",
"ret",
"=",
"this",
".",
... | Selects the columns if only if there is not already select sources.
@example
var ds = DB.from("items"); //SELECT * FROM items
ds.select("a"); //SELECT a FROM items;
ds.select("a").selectIfNoSource("a", "b"). //SELECT a FROM items;
ds.selectIfNoSource("a", "b"). //SELECT a, b FROM items;
@param cols columns to selec... | [
"Selects",
"the",
"columns",
"if",
"only",
"if",
"there",
"is",
"not",
"already",
"select",
"sources",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L1791-L1799 | train | |
C2FO/patio | lib/dataset/query.js | function (cols) {
cols = argsToArray(arguments);
var currentSelect = this.__opts.select;
return this.select.apply(this, (currentSelect || []).concat(cols));
} | javascript | function (cols) {
cols = argsToArray(arguments);
var currentSelect = this.__opts.select;
return this.select.apply(this, (currentSelect || []).concat(cols));
} | [
"function",
"(",
"cols",
")",
"{",
"cols",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"var",
"currentSelect",
"=",
"this",
".",
"__opts",
".",
"select",
";",
"return",
"this",
".",
"select",
".",
"apply",
"(",
"this",
",",
"(",
"currentSelect",
"|... | Returns a copy of the dataset with the given columns added
to the existing selected columns. If no columns are currently selected
it will just select the columns given.
@example
DB.from("items").select("a").select("b").sql;
//=> SELECT b FROM items
DB.from("items").select("a").selectMore("b", "c", "d").sql
//=> SELEC... | [
"Returns",
"a",
"copy",
"of",
"the",
"dataset",
"with",
"the",
"given",
"columns",
"added",
"to",
"the",
"existing",
"selected",
"columns",
".",
"If",
"no",
"columns",
"are",
"currently",
"selected",
"it",
"will",
"just",
"select",
"the",
"columns",
"given",... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L1848-L1852 | train | |
C2FO/patio | lib/dataset/query.js | 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 | 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);
... | [
"function",
"(",
"type",
",",
"dataset",
",",
"options",
")",
"{",
"var",
"ds",
"=",
"this",
".",
"_compoundFromSelf",
"(",
")",
".",
"mergeOptions",
"(",
"{",
"compounds",
":",
"(",
"array",
".",
"toArray",
"(",
"this",
".",
"__opts",
".",
"compounds"... | Add the dataset to the list of compounds
@param {String} type the type of compound (i.e. "union", "intersect")
@param {patio.Dataset} dataset the dataset to add to
@param [Object] [options={}] compound option to use (i.e {all : true})
@return {patio.Dataset} ds with the dataset added to the compounds. | [
"Add",
"the",
"dataset",
"to",
"the",
"list",
"of",
"compounds"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L2097-L2102 | train | |
C2FO/patio | lib/dataset/query.js | 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 Identifie... | javascript | 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 Identifie... | [
"function",
"(",
"op",
",",
"obj",
")",
"{",
"var",
"pairs",
"=",
"[",
"]",
";",
"if",
"(",
"Expression",
".",
"isConditionSpecifier",
"(",
"obj",
")",
")",
"{",
"if",
"(",
"isHash",
"(",
"obj",
")",
")",
"{",
"obj",
"=",
"array",
".",
"toArray",... | Creates a boolean expression that each key is compared to its value using the provided operator.
@example
ds.__createBoolExpression("gt", {x : 1, y:2, z : 5}) //=> WHERE ((x > 1) AND (y > 2) AND (z > 5))
ds.__createBoolExpression("gt", [[x, 1], [y,2], [z, 5]) //=> WHERE ((x > 1) AND (y > 2) AND (z > 5))
ds.__createBo... | [
"Creates",
"a",
"boolean",
"expression",
"that",
"each",
"key",
"is",
"compared",
"to",
"its",
"value",
"using",
"the",
"provided",
"operator",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/query.js#L2262-L2273 | train | |
C2FO/patio | lib/database/schemaGenerators.js | function (name, type, opts) {
opts = opts || {};
this.columns.push(merge({name:name, type:type}, opts));
if (opts.index) {
this.index(name);
}
} | javascript | function (name, type, opts) {
opts = opts || {};
this.columns.push(merge({name:name, type:type}, opts));
if (opts.index) {
this.index(name);
}
} | [
"function",
"(",
"name",
",",
"type",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"columns",
".",
"push",
"(",
"merge",
"(",
"{",
"name",
":",
"name",
",",
"type",
":",
"type",
"}",
",",
"opts",
")",
")",
";"... | Add a column with the given name, type, and opts to the DDL.
<pre class="code">
DB.createTable("test", function(){
this.column("num", "integer");
//=> num INTEGER
this.column("name", String, {allowNull : false, "default" : "a");
//=> name varchar(255) NOT NULL DEFAULT 'a'
this.column("ip", "inet");
//=> ip inet
});
</... | [
"Add",
"a",
"column",
"with",
"the",
"given",
"name",
"type",
"and",
"opts",
"to",
"the",
"DDL",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/database/schemaGenerators.js#L143-L149 | train | |
C2FO/patio | lib/database/schemaGenerators.js | 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.serialPrimaryKe... | javascript | 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.serialPrimaryKe... | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"name",
")",
")",
"{",
"return",
"this",
".",
"__compositePrimaryKey",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"else",
"{",
"var",
"args",
"=",
"argsToArr... | Adds an auto-incrementing primary key column or a primary key constraint to the DDL.
To create a constraint, the first argument should be an array of columns
specifying the primary key columns. To create an auto-incrementing primary key
column, a single column can be used. In both cases, an options hash can be used
as ... | [
"Adds",
"an",
"auto",
"-",
"incrementing",
"primary",
"key",
"column",
"or",
"a",
"primary",
"key",
"constraint",
"to",
"the",
"DDL",
".",
"To",
"create",
"a",
"constraint",
"the",
"first",
"argument",
"should",
"be",
"an",
"array",
"of",
"columns",
"speci... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/database/schemaGenerators.js#L263-L276 | train | |
C2FO/patio | lib/database/schemaGenerators.js | function (name, newName, opts) {
opts = opts || {};
this.operations.push(merge({op:"renameColumn", name:name, newName:newName}, opts));
} | javascript | function (name, newName, opts) {
opts = opts || {};
this.operations.push(merge({op:"renameColumn", name:name, newName:newName}, opts));
} | [
"function",
"(",
"name",
",",
"newName",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"operations",
".",
"push",
"(",
"merge",
"(",
"{",
"op",
":",
"\"renameColumn\"",
",",
"name",
":",
"name",
",",
"newName",
":",
... | Modify a column's name in the DDL for the table.
@example
DB.alterTable("artist", function(){
this.renameColumn("name", "artistName");
//=> RENAME COLUMN name TO artist_name
}); | [
"Modify",
"a",
"column",
"s",
"name",
"in",
"the",
"DDL",
"for",
"the",
"table",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/database/schemaGenerators.js#L600-L603 | train | |
C2FO/patio | lib/database/schemaGenerators.js | function (name, type, opts) {
opts = opts || {};
this.operations.push(merge({op:"setColumnType", name:name, type:type}, opts));
} | javascript | function (name, type, opts) {
opts = opts || {};
this.operations.push(merge({op:"setColumnType", name:name, type:type}, opts));
} | [
"function",
"(",
"name",
",",
"type",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"operations",
".",
"push",
"(",
"merge",
"(",
"{",
"op",
":",
"\"setColumnType\"",
",",
"name",
":",
"name",
",",
"type",
":",
"ty... | Modify a column's type in the DDL for the table.
@example
DB.alterTable("artist", function(){
this.setColumnType("artist_name", 'char(10)');
//=> ALTER COLUMN artist_name TYPE char(10)
}); | [
"Modify",
"a",
"column",
"s",
"type",
"in",
"the",
"DDL",
"for",
"the",
"table",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/database/schemaGenerators.js#L626-L629 | train | |
C2FO/patio | lib/plugins/query.js | 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 {
... | javascript | 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 {
... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__isNew",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"this",
".",
"dataset",
".",
"naked",
"(",
")",
".",
"filter",
"(",
"this",
".",
"_getPrimaryKeyQuery",
"(",
")",
")",
".",
"o... | Forces the reload of the data for a particular model instance. The Promise returned is resolved with the
model.
@example
myModel.reload().chain(function(model){
//model === myModel
});
@return {comb.Promise} resolved with the model instance. | [
"Forces",
"the",
"reload",
"of",
"the",
"data",
"for",
"a",
"particular",
"model",
"instance",
".",
"The",
"Promise",
"returned",
"is",
"resolved",
"with",
"the",
"model",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/query.js#L75-L85 | train | |
C2FO/patio | lib/plugins/query.js | function (vals, /*?object*/query, options) {
options = options || {};
var dataset = this.dataset;
return this._checkTransaction(options, function () {
if (!isUndefined(query)) {
dataset = dataset.filter(query);
}
ret... | javascript | function (vals, /*?object*/query, options) {
options = options || {};
var dataset = this.dataset;
return this._checkTransaction(options, function () {
if (!isUndefined(query)) {
dataset = dataset.filter(query);
}
ret... | [
"function",
"(",
"vals",
",",
"/*?object*/",
"query",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"dataset",
"=",
"this",
".",
"dataset",
";",
"return",
"this",
".",
"_checkTransaction",
"(",
"options",
",",
"function... | Update multiple rows with a set of values.
@example
var User = patio.getModel("user");
//BEGIN
//UPDATE `user` SET `password` = NULL WHERE (`last_accessed` <= '2011-01-27')
//COMMIT
User.update({password : null}, function(){
return this.lastAccessed.lte(comb.date.add(new Date(), "year", -1));
});
//same as
User.updat... | [
"Update",
"multiple",
"rows",
"with",
"a",
"set",
"of",
"values",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/query.js#L513-L522 | train | |
C2FO/patio | lib/plugins/query.js | 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 | function (id, options) {
var self = this;
return this._checkTransaction(options, function () {
return self.findById(id).chain(function (model) {
return model ? model.remove(options) : null;
});
});
} | [
"function",
"(",
"id",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"this",
".",
"_checkTransaction",
"(",
"options",
",",
"function",
"(",
")",
"{",
"return",
"self",
".",
"findById",
"(",
"id",
")",
".",
"chain",
"(",
"funct... | Similar to remove but takes an id or an array for a composite key.
@example
User.removeById(1);
@param id id or an array for a composite key, to find the model by
@param {Object} [options] additional options.
@param {Boolean} [options.transaction] boolean indicating if a transaction should be used when
removing the ... | [
"Similar",
"to",
"remove",
"but",
"takes",
"an",
"id",
"or",
"an",
"array",
"for",
"a",
"composite",
"key",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/query.js#L579-L586 | train | |
C2FO/patio | lib/plugins/query.js | 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)) {
... | javascript | 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)) {
... | [
"function",
"(",
"items",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"isArr",
"=",
"isArray",
"(",
"items",
")",
",",
"Self",
"=",
"this",
";",
"return",
"this",
".",
"_checkTransaction",
"(",
"options",
",",
"fu... | Save either a new model or list of models to the database.
@example
var Student = patio.getModel("student");
Student.save([
{
firstName:"Bob",
lastName:"Yukon",
gpa:3.689,
classYear:"Senior"
},
{
firstName:"Greg",
lastName:"Horn",
gpa:3.689,
classYear:"Sohpmore"
},
{
firstName:"Sara",
lastName:"Malloc",
gpa:4.0,
class... | [
"Save",
"either",
"a",
"new",
"model",
"or",
"list",
"of",
"models",
"to",
"the",
"database",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/plugins/query.js#L644-L659 | train | |
C2FO/patio | lib/time.js | 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)) {
... | javascript | 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)) {
... | [
"function",
"(",
"dt",
",",
"format",
")",
"{",
"var",
"ret",
"=",
"\"\"",
";",
"if",
"(",
"isInstanceOf",
"(",
"dt",
",",
"SQL",
".",
"Time",
")",
")",
"{",
"ret",
"=",
"this",
".",
"timeToString",
"(",
"dt",
",",
"format",
")",
";",
"}",
"els... | Converts a date to a string.
@example
var date = new Date(2004, 1, 1),
timeStamp = new sql.TimeStamp(2004, 1, 1, 12, 12, 12),
dateTime = new sql.DateTime(2004, 1, 1, 12, 12, 12),
year = new sql.Year(2004),
time = new sql.Time(12,12,12),
//convert years
patio.dateToString(year); //=> '2004'
patio.yearFormat = "yy";
p... | [
"Converts",
"a",
"date",
"to",
"a",
"string",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/time.js#L390-L404 | train | |
C2FO/patio | lib/time.js | 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 ne... | javascript | 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 ne... | [
"function",
"(",
"dt",
",",
"format",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"this",
".",
"convertTwoDigitYears",
")",
"{",
"ret",
"=",
"date",
".",
"parse",
"(",
"dt",
",",
"this",
".",
"TWO_YEAR_DATE_FORMAT",
")",
";",
"}",
"if",
"(",
"!",
"ret"... | Converts a date string to a Date
@example
var date = new Date(2004, 1,1,0,0,0);
patio.stringToDate('2004-02-01'); //=> date
patio.dateFormat = patio.TWO_YEAR_DATE_FORMAT;
patio.stringToDate('04-02-01'); //=> date
@param {String} dt the string to convert to a Date
@param {String} [format=patio.Time#dateFormat] the f... | [
"Converts",
"a",
"date",
"string",
"to",
"a",
"Date"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/time.js#L469-L481 | train | |
C2FO/patio | lib/adapters/mysql.js | function (args) {
args = argsToArray(arguments);
return !args.length ? this._super(arguments) : this.group.apply(this, args);
} | javascript | function (args) {
args = argsToArray(arguments);
return !args.length ? this._super(arguments) : this.group.apply(this, args);
} | [
"function",
"(",
"args",
")",
"{",
"args",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"return",
"!",
"args",
".",
"length",
"?",
"this",
".",
"_super",
"(",
"arguments",
")",
":",
"this",
".",
"group",
".",
"apply",
"(",
"this",
",",
"args",
"... | Use GROUP BY instead of DISTINCT ON if arguments are provided. | [
"Use",
"GROUP",
"BY",
"instead",
"of",
"DISTINCT",
"ON",
"if",
"arguments",
"are",
"provided",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L148-L151 | train | |
C2FO/patio | lib/adapters/mysql.js | function (cols, terms, opts) {
opts = opts || {};
cols = toArray(cols).map(this.stringToIdentifier, this);
return this.filter(sql.literal(this.fullTextSql(cols, terms, opts)));
} | javascript | function (cols, terms, opts) {
opts = opts || {};
cols = toArray(cols).map(this.stringToIdentifier, this);
return this.filter(sql.literal(this.fullTextSql(cols, terms, opts)));
} | [
"function",
"(",
"cols",
",",
"terms",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"cols",
"=",
"toArray",
"(",
"cols",
")",
".",
"map",
"(",
"this",
".",
"stringToIdentifier",
",",
"this",
")",
";",
"return",
"this",
".",
"f... | Adds full text filter | [
"Adds",
"full",
"text",
"filter"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L159-L163 | train | |
C2FO/patio | lib/adapters/mysql.js | 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 | 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" : "");
} | [
"function",
"(",
"cols",
",",
"term",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"return",
"format",
"(",
"\"MATCH %s AGAINST (%s%s)\"",
",",
"this",
".",
"literal",
"(",
"toArray",
"(",
"cols",
")",
")",
",",
"this",
".",
"lite... | MySQL specific full text search syntax. | [
"MySQL",
"specific",
"full",
"text",
"search",
"syntax",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L166-L170 | train | |
C2FO/patio | lib/adapters/mysql.js | 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 | 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)))];
} | [
"function",
"(",
"columns",
",",
"values",
")",
"{",
"return",
"[",
"this",
".",
"insertSql",
"(",
"columns",
",",
"sql",
".",
"literal",
"(",
"'VALUES '",
"+",
"values",
".",
"map",
"(",
"function",
"(",
"r",
")",
"{",
"return",
"this",
".",
"litera... | MySQL specific syntax for inserting multiple values at once. | [
"MySQL",
"specific",
"syntax",
"for",
"inserting",
"multiple",
"values",
"at",
"once",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L216-L221 | train | |
C2FO/patio | lib/adapters/mysql.js | 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 | 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);
}
} | [
"function",
"(",
"sql",
")",
"{",
"if",
"(",
"this",
".",
"_joinedDataset",
")",
"{",
"return",
"format",
"(",
"\" %s FROM %s%s\"",
",",
"this",
".",
"_sourceList",
"(",
"this",
".",
"__opts",
".",
"from",
"[",
"0",
"]",
")",
",",
"this",
".",
"_sour... | Consider the first table in the joined dataset is the table to delete from, but include the others for the purposes of selecting rows. | [
"Consider",
"the",
"first",
"table",
"in",
"the",
"joined",
"dataset",
"is",
"the",
"table",
"to",
"delete",
"from",
"but",
"include",
"the",
"others",
"for",
"the",
"purposes",
"of",
"selecting",
"rows",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L242-L248 | train | |
C2FO/patio | lib/adapters/mysql.js | function (sql) {
var values = this.__opts.values;
if (isArray(values) && !values.length) {
return " ()";
} else {
return this._super(arguments);
}
} | javascript | function (sql) {
var values = this.__opts.values;
if (isArray(values) && !values.length) {
return " ()";
} else {
return this._super(arguments);
}
} | [
"function",
"(",
"sql",
")",
"{",
"var",
"values",
"=",
"this",
".",
"__opts",
".",
"values",
";",
"if",
"(",
"isArray",
"(",
"values",
")",
"&&",
"!",
"values",
".",
"length",
")",
"{",
"return",
"\" ()\"",
";",
"}",
"else",
"{",
"return",
"this",... | alias replace_clause_methods insert_clause_methods MySQL doesn't use the standard DEFAULT VALUES for empty values. | [
"alias",
"replace_clause_methods",
"insert_clause_methods",
"MySQL",
"doesn",
"t",
"use",
"the",
"standard",
"DEFAULT",
"VALUES",
"for",
"empty",
"values",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L252-L259 | train | |
C2FO/patio | lib/adapters/mysql.js | 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;
... | javascript | 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;
... | [
"function",
"(",
")",
"{",
"var",
"ret",
"=",
"\"\"",
";",
"var",
"updateCols",
"=",
"this",
".",
"__opts",
".",
"onDuplicateKeyUpdate",
";",
"if",
"(",
"updateCols",
")",
"{",
"var",
"updateVals",
"=",
"null",
",",
"l",
",",
"last",
";",
"if",
"(",
... | MySQL specific syntax for ON DUPLICATE KEY UPDATE | [
"MySQL",
"specific",
"syntax",
"for",
"ON",
"DUPLICATE",
"KEY",
"UPDATE"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L296-L320 | train | |
C2FO/patio | lib/adapters/mysql.js | 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";
... | javascript | 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";
... | [
"function",
"(",
"type",
")",
"{",
"var",
"ret",
"=",
"null",
",",
"meth",
";",
"if",
"(",
"isString",
"(",
"type",
")",
")",
"{",
"ret",
"=",
"this",
".",
"_static",
".",
"CAST_TYPES",
"[",
"type",
"]",
"||",
"this",
".",
"_super",
"(",
"argumen... | MySQL's cast rules are restrictive in that you can't just cast to any possible database type. | [
"MySQL",
"s",
"cast",
"rules",
"are",
"restrictive",
"in",
"that",
"you",
"can",
"t",
"just",
"cast",
"to",
"any",
"possible",
"database",
"type",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L477-L497 | train | |
C2FO/patio | lib/adapters/mysql.js | 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(ta... | javascript | 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(ta... | [
"function",
"(",
"table",
",",
"opts",
")",
"{",
"var",
"indexes",
"=",
"{",
"}",
";",
"var",
"removeIndexes",
"=",
"[",
"]",
";",
"var",
"m",
"=",
"this",
".",
"outputIdentifierFunc",
";",
"var",
"im",
"=",
"this",
".",
"inputIdentifierFunc",
";",
"... | Use SHOW INDEX FROM to get the index information for the table. | [
"Use",
"SHOW",
"INDEX",
"FROM",
"to",
"get",
"the",
"index",
"information",
"for",
"the",
"table",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L500-L526 | train | |
C2FO/patio | lib/adapters/mysql.js | 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(... | javascript | 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(... | [
"function",
"(",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"!",
"this",
".",
"__serverVersion",
")",
"{",
"var",
"self",
"=",
"this",
";",
"ret",
"=",
"this",
".",
"get",
"(",
"sql",
".",
"version",
"(",
")",
".",
"sqlFunction",
")",
".",
"chain",
... | Get version of MySQL server, used for determined capabilities. | [
"Get",
"version",
"of",
"MySQL",
"server",
"used",
"for",
"determined",
"capabilities",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L529-L541 | train | |
C2FO/patio | lib/adapters/mysql.js | function (opts) {
var m = this.outputIdentifierFunc;
return this.metadataDataset.withSql('SHOW TABLES').map(function (r) {
return m(r[Object.keys(r)[0]]);
});
} | javascript | function (opts) {
var m = this.outputIdentifierFunc;
return this.metadataDataset.withSql('SHOW TABLES').map(function (r) {
return m(r[Object.keys(r)[0]]);
});
} | [
"function",
"(",
"opts",
")",
"{",
"var",
"m",
"=",
"this",
".",
"outputIdentifierFunc",
";",
"return",
"this",
".",
"metadataDataset",
".",
"withSql",
"(",
"'SHOW TABLES'",
")",
".",
"map",
"(",
"function",
"(",
"r",
")",
"{",
"return",
"m",
"(",
"r",... | Return an array of strings specifying table names in the current database. | [
"Return",
"an",
"array",
"of",
"strings",
"specifying",
"table",
"names",
"in",
"the",
"current",
"database",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L544-L549 | train | |
C2FO/patio | lib/adapters/mysql.js | 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... | javascript | 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... | [
"function",
"(",
"table",
",",
"op",
")",
"{",
"var",
"ret",
"=",
"new",
"Promise",
"(",
")",
",",
"self",
"=",
"this",
";",
"if",
"(",
"op",
".",
"op",
"===",
"\"addColumn\"",
")",
"{",
"var",
"related",
"=",
"op",
".",
"table",
";",
"if",
"("... | Use MySQL specific syntax for rename column, set column type, and drop index cases. | [
"Use",
"MySQL",
"specific",
"syntax",
"for",
"rename",
"column",
"set",
"column",
"type",
"and",
"drop",
"index",
"cases",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L565-L603 | train | |
C2FO/patio | lib/adapters/mysql.js | function (conn, opts) {
var self = this;
return this.__setTransactionIsolation(conn, opts).chain(function () {
return self.__logConnectionExecute(conn, self.beginTransactionSql);
});
} | javascript | function (conn, opts) {
var self = this;
return this.__setTransactionIsolation(conn, opts).chain(function () {
return self.__logConnectionExecute(conn, self.beginTransactionSql);
});
} | [
"function",
"(",
"conn",
",",
"opts",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"this",
".",
"__setTransactionIsolation",
"(",
"conn",
",",
"opts",
")",
".",
"chain",
"(",
"function",
"(",
")",
"{",
"return",
"self",
".",
"__logConnectionExecu... | MySQL needs to set transaction isolation before beginning a transaction | [
"MySQL",
"needs",
"to",
"set",
"transaction",
"isolation",
"before",
"beginning",
"a",
"transaction"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L606-L611 | train | |
C2FO/patio | lib/adapters/mysql.js | function (column) {
if (isString(column.type) && column.type.match(/string/i) && column.text) {
delete column["default"];
}
return this._super(arguments, [column]);
} | javascript | function (column) {
if (isString(column.type) && column.type.match(/string/i) && column.text) {
delete column["default"];
}
return this._super(arguments, [column]);
} | [
"function",
"(",
"column",
")",
"{",
"if",
"(",
"isString",
"(",
"column",
".",
"type",
")",
"&&",
"column",
".",
"type",
".",
"match",
"(",
"/",
"string",
"/",
"i",
")",
"&&",
"column",
".",
"text",
")",
"{",
"delete",
"column",
"[",
"\"default\""... | MySQL doesn't allow default values on text columns, so ignore if it the generic text type is used | [
"MySQL",
"doesn",
"t",
"allow",
"default",
"values",
"on",
"text",
"columns",
"so",
"ignore",
"if",
"it",
"the",
"generic",
"text",
"type",
"is",
"used"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L627-L632 | train | |
C2FO/patio | lib/adapters/mysql.js | 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").... | javascript | 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").... | [
"function",
"(",
"conn",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"s",
"=",
"opts",
".",
"prepare",
",",
"self",
"=",
"this",
";",
"if",
"(",
"s",
")",
"{",
"return",
"this",
".",
"__logConnectionExecute",
"(",
"con... | Prepare the XA transaction for a two-phase commit if the prepare option is given. | [
"Prepare",
"the",
"XA",
"transaction",
"for",
"a",
"two",
"-",
"phase",
"commit",
"if",
"the",
"prepare",
"option",
"is",
"given",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L636-L646 | train | |
C2FO/patio | lib/adapters/mysql.js | 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)) {
... | javascript | 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)) {
... | [
"function",
"(",
"name",
",",
"generator",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"engine",
"=",
"options",
".",
"engine",
",",
"charset",
"=",
"options",
".",
"charset",
",",
"collate",
"=",
"options",
".",
... | Use MySQL specific syntax for engine type and character encoding | [
"Use",
"MySQL",
"specific",
"syntax",
"for",
"engine",
"type",
"and",
"character",
"encoding"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L649-L670 | train | |
C2FO/patio | lib/adapters/mysql.js | 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 i... | javascript | 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 i... | [
"function",
"(",
"tableName",
",",
"index",
")",
"{",
"var",
"indexName",
"=",
"this",
".",
"__quoteIdentifier",
"(",
"index",
".",
"name",
"||",
"this",
".",
"__defaultIndexName",
"(",
"tableName",
",",
"index",
".",
"columns",
")",
")",
",",
"t",
"=",
... | Handle MySQL specific index SQL syntax | [
"Handle",
"MySQL",
"specific",
"index",
"SQL",
"syntax"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L673-L689 | train | |
C2FO/patio | lib/adapters/mysql.js | 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 " + ... | javascript | 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 " + ... | [
"function",
"(",
"conn",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"s",
"=",
"opts",
".",
"prepare",
";",
"var",
"logConnectionExecute",
"=",
"comb",
"(",
"\"__logConnectionExecute\"",
")",
";",
"if",
"(",
"s",
")",
"{",... | Rollback the currently open XA transaction | [
"Rollback",
"the",
"currently",
"open",
"XA",
"transaction"
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L692-L709 | train | |
C2FO/patio | lib/adapters/mysql.js | 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")];
... | javascript | 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")];
... | [
"function",
"(",
"tableName",
",",
"opts",
")",
"{",
"var",
"m",
"=",
"this",
".",
"outputIdentifierFunc",
",",
"im",
"=",
"this",
".",
"inputIdentifierFunc",
",",
"self",
"=",
"this",
";",
"return",
"this",
".",
"metadataDataset",
".",
"withSql",
"(",
"... | Use the MySQL specific DESCRIBE syntax to get a table description. | [
"Use",
"the",
"MySQL",
"specific",
"DESCRIBE",
"syntax",
"to",
"get",
"a",
"table",
"description",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/adapters/mysql.js#L717-L741 | train | |
C2FO/patio | lib/dataset/actions.js | 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 | 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();
... | [
"function",
"(",
"block",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"ret",
"=",
"asyncArray",
"(",
"this",
".",
"forEach",
"(",
")",
".",
"chain",
"(",
"function",
"(",
"records",
")",
"{",
"return",
"self",
".",
"postLoad",
"(",... | Returns a Promise that is resolved with an array with all records in the dataset.
If a block is given, the array is iterated over after all items have been loaded.
@example
// SELECT * FROM table
DB.from("table").all().chain(function(res){
//res === [{id : 1, ...}, {id : 2, ...}, ...];
});
// Iterate over all rows in... | [
"Returns",
"a",
"Promise",
"that",
"is",
"resolved",
"with",
"an",
"array",
"with",
"all",
"records",
"in",
"the",
"dataset",
".",
"If",
"a",
"block",
"is",
"given",
"the",
"array",
"is",
"iterated",
"over",
"after",
"all",
"items",
"have",
"been",
"load... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L121-L130 | train | |
C2FO/patio | lib/dataset/actions.js | function (cb) {
return this.__aggregateDataset().get(sql.COUNT(sql.literal("*")).as("count")).chain(function (res) {
return parseInt(res, 10);
}).classic(cb);
} | javascript | function (cb) {
return this.__aggregateDataset().get(sql.COUNT(sql.literal("*")).as("count")).chain(function (res) {
return parseInt(res, 10);
}).classic(cb);
} | [
"function",
"(",
"cb",
")",
"{",
"return",
"this",
".",
"__aggregateDataset",
"(",
")",
".",
"get",
"(",
"sql",
".",
"COUNT",
"(",
"sql",
".",
"literal",
"(",
"\"*\"",
")",
")",
".",
"as",
"(",
"\"count\"",
")",
")",
".",
"chain",
"(",
"function",
... | Returns a promise that is resolved with the number of records in the dataset.
@example
// SELECT COUNT(*) AS count FROM table LIMIT 1
DB.from("table").count().chain(function(count){
//count === 3;
});
@param {Function} [cb] the callback to invoke when the action is done.
@return {comb.Promise} a promise that is res... | [
"Returns",
"a",
"promise",
"that",
"is",
"resolved",
"with",
"the",
"number",
"of",
"records",
"in",
"the",
"dataset",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L166-L170 | train | |
C2FO/patio | lib/dataset/actions.js | 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) {
... | javascript | 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) {
... | [
"function",
"(",
"block",
",",
"cb",
")",
"{",
"var",
"rowCb",
",",
"ret",
";",
"if",
"(",
"this",
".",
"__opts",
".",
"graph",
")",
"{",
"ret",
"=",
"this",
".",
"graphEach",
"(",
"block",
")",
";",
"}",
"else",
"{",
"ret",
"=",
"this",
".",
... | Iterates over the records in the dataset as they are returned from the
database adapter.
@example
// SELECT * FROM table
DB.from("table").forEach(function(row){
//....do something
});
@param {Function} [block] the block to invoke for each row.
@param {Function} [cb] the callback to invoke when the action is done.
@... | [
"Iterates",
"over",
"the",
"records",
"in",
"the",
"dataset",
"as",
"they",
"are",
"returned",
"from",
"the",
"database",
"adapter",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L214-L230 | train | |
C2FO/patio | lib/dataset/actions.js | 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;
... | javascript | 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;
... | [
"function",
"(",
"args",
")",
"{",
"args",
"=",
"comb",
"(",
"arguments",
")",
".",
"toArray",
"(",
")",
";",
"var",
"cb",
",",
"block",
"=",
"isFunction",
"(",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
")",
"?",
"args",
".",
"pop",
"(... | If a integer argument is given, it is interpreted as a limit, and then returns all
matching records up to that limit.
If no arguments are passed, it returns the first matching record.
If a function taking no arguments is passed in as the last parameter then it
is assumed to be a filter block. If the a funciton is pas... | [
"If",
"a",
"integer",
"argument",
"is",
"given",
"it",
"is",
"interpreted",
"as",
"a",
"limit",
"and",
"then",
"returns",
"all",
"matching",
"records",
"up",
"to",
"that",
"limit",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L367-L387 | train | |
C2FO/patio | lib/dataset/actions.js | 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 () {
... | javascript | 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 () {
... | [
"function",
"(",
"columns",
",",
"values",
",",
"opts",
",",
"cb",
")",
"{",
"if",
"(",
"isFunction",
"(",
"opts",
")",
")",
"{",
"cb",
"=",
"opts",
";",
"opts",
"=",
"null",
";",
"}",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"ret",
"... | Inserts multiple records into the associated table. This method can be
used to efficiently insert a large number of records into a table in a
single query if the database supports it. Inserts
are automatically wrapped in a transaction.
This method is called with a columns array and an array of value arrays:
<pre class... | [
"Inserts",
"multiple",
"records",
"into",
"the",
"associated",
"table",
".",
"This",
"method",
"can",
"be",
"used",
"to",
"efficiently",
"insert",
"a",
"large",
"number",
"of",
"records",
"into",
"a",
"table",
"in",
"a",
"single",
"query",
"if",
"the",
"da... | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L459-L504 | train | |
C2FO/patio | lib/dataset/actions.js | 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 | 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);
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"argsToArray",
"(",
"arguments",
")",
";",
"var",
"cb",
"=",
"isFunction",
"(",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
")",
"?",
"args",
".",
"pop",
"(",
")",
":",
"null",
";",
"return",
... | Inserts values into the associated table. The returned value is generally
the value of the primary key for the inserted row, but that is adapter dependent.
@example
// INSERT INTO items DEFAULT VALUES
DB.from("items").insert()
// INSERT INTO items DEFAULT VALUES
DB.from("items").insert({});
// INSERT INTO items VAL... | [
"Inserts",
"values",
"into",
"the",
"associated",
"table",
".",
"The",
"returned",
"value",
"is",
"generally",
"the",
"value",
"of",
"the",
"primary",
"key",
"for",
"the",
"inserted",
"row",
"but",
"that",
"is",
"adapter",
"dependent",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L604-L608 | train | |
C2FO/patio | lib/dataset/actions.js | function (column, cb) {
return this.__aggregateDataset().get(sql.max(column).minus(sql.min(column)), cb);
} | javascript | function (column, cb) {
return this.__aggregateDataset().get(sql.max(column).minus(sql.min(column)), cb);
} | [
"function",
"(",
"column",
",",
"cb",
")",
"{",
"return",
"this",
".",
"__aggregateDataset",
"(",
")",
".",
"get",
"(",
"sql",
".",
"max",
"(",
"column",
")",
".",
"minus",
"(",
"sql",
".",
"min",
"(",
"column",
")",
")",
",",
"cb",
")",
";",
"... | Returns a promise that is resolved with the interval between minimum and maximum values
for the given column.
@example
// SELECT (max(id) - min(id)) FROM table LIMIT 1
DB.from("table").interval("id").chain(function(interval){
//(e.g) interval === 6
});
@param {String|patio.sql.Identifier} column to find the interval ... | [
"Returns",
"a",
"promise",
"that",
"is",
"resolved",
"with",
"the",
"interval",
"between",
"minimum",
"and",
"maximum",
"values",
"for",
"the",
"given",
"column",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L680-L682 | train | |
C2FO/patio | lib/dataset/actions.js | function (args) {
if (!this.__opts.order) {
throw new QueryError("No order specified");
}
var ds = this.reverse();
return ds.first.apply(ds, arguments);
} | javascript | function (args) {
if (!this.__opts.order) {
throw new QueryError("No order specified");
}
var ds = this.reverse();
return ds.first.apply(ds, arguments);
} | [
"function",
"(",
"args",
")",
"{",
"if",
"(",
"!",
"this",
".",
"__opts",
".",
"order",
")",
"{",
"throw",
"new",
"QueryError",
"(",
"\"No order specified\"",
")",
";",
"}",
"var",
"ds",
"=",
"this",
".",
"reverse",
"(",
")",
";",
"return",
"ds",
"... | Reverses the order and then runs first. Note that this
will not necessarily give you the last record in the dataset,
unless you have an unambiguous order.
@example
// SELECT * FROM table ORDER BY id DESC LIMIT 1
DB.from("table").order("id").last().chain(function(lastItem){
//...(e.g lastItem === {id : 10})
});
// S... | [
"Reverses",
"the",
"order",
"and",
"then",
"runs",
"first",
".",
"Note",
"that",
"this",
"will",
"not",
"necessarily",
"give",
"you",
"the",
"last",
"record",
"in",
"the",
"dataset",
"unless",
"you",
"have",
"an",
"unambiguous",
"order",
"."
] | 6dba197e468d36189cd74846c0cdbf0755a0ff8d | https://github.com/C2FO/patio/blob/6dba197e468d36189cd74846c0cdbf0755a0ff8d/lib/dataset/actions.js#L708-L714 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.