sequelize
Version:
Multi dialect ORM for Node.JS/io.js
1,350 lines • 452 kB
JSON
{
"type": "File",
"start": 0,
"end": 3950,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 109,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 3950,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 109,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "VariableDeclaration",
"start": 15,
"end": 52,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 37
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 21,
"end": 51,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 26,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "Utils"
},
"name": "Utils"
},
"init": {
"type": "CallExpression",
"start": 29,
"end": 51,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 36
}
},
"callee": {
"type": "Identifier",
"start": 29,
"end": 36,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 21
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 37,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 22
},
"end": {
"line": 3,
"column": 35
}
},
"extra": {
"rawValue": "../../utils",
"raw": "'../../utils'"
},
"value": "../../utils"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 53,
"end": 94,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 41
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 59,
"end": 93,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 40
}
},
"id": {
"type": "Identifier",
"start": 59,
"end": 66,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 13
},
"identifierName": "Promise"
},
"name": "Promise"
},
"init": {
"type": "CallExpression",
"start": 69,
"end": 93,
"loc": {
"start": {
"line": 4,
"column": 16
},
"end": {
"line": 4,
"column": 40
}
},
"callee": {
"type": "Identifier",
"start": 69,
"end": 76,
"loc": {
"start": {
"line": 4,
"column": 16
},
"end": {
"line": 4,
"column": 23
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 77,
"end": 92,
"loc": {
"start": {
"line": 4,
"column": 24
},
"end": {
"line": 4,
"column": 39
}
},
"extra": {
"rawValue": "../../promise",
"raw": "'../../promise'"
},
"value": "../../promise"
}
]
}
}
],
"kind": "const",
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n Returns an object that treats SQLite's inabilities to do certain queries.\n\n @class QueryInterface\n @static\n @private\n ",
"start": 96,
"end": 221,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 12,
"column": 3
}
}
},
{
"type": "CommentBlock",
"value": "*\n A wrapper that fixes SQLite's inability to remove columns from existing tables.\n It will create a backup of the table, drop the table afterwards and create a\n new table with the same name but without the obsolete column.\n\n @method removeColumn\n @for QueryInterface\n\n @param {String} tableName The name of the table.\n @param {String} attributeName The name of the attribute that we want to remove.\n @param {Object} options\n @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries\n\n @since 1.6.0\n @private\n ",
"start": 223,
"end": 833,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 29,
"column": 3
}
}
}
]
},
{
"type": "FunctionDeclaration",
"start": 834,
"end": 1319,
"loc": {
"start": {
"line": 30,
"column": 0
},
"end": {
"line": 42,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 843,
"end": 855,
"loc": {
"start": {
"line": 30,
"column": 9
},
"end": {
"line": 30,
"column": 21
},
"identifierName": "removeColumn"
},
"name": "removeColumn",
"leadingComments": null
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 856,
"end": 865,
"loc": {
"start": {
"line": 30,
"column": 22
},
"end": {
"line": 30,
"column": 31
},
"identifierName": "tableName"
},
"name": "tableName"
},
{
"type": "Identifier",
"start": 867,
"end": 880,
"loc": {
"start": {
"line": 30,
"column": 33
},
"end": {
"line": 30,
"column": 46
},
"identifierName": "attributeName"
},
"name": "attributeName"
},
{
"type": "Identifier",
"start": 882,
"end": 889,
"loc": {
"start": {
"line": 30,
"column": 48
},
"end": {
"line": 30,
"column": 55
},
"identifierName": "options"
},
"name": "options"
}
],
"body": {
"type": "BlockStatement",
"start": 891,
"end": 1319,
"loc": {
"start": {
"line": 30,
"column": 57
},
"end": {
"line": 42,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 895,
"end": 919,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 31,
"column": 26
}
},
"expression": {
"type": "AssignmentExpression",
"start": 895,
"end": 918,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 31,
"column": 25
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 895,
"end": 902,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 31,
"column": 9
},
"identifierName": "options"
},
"name": "options"
},
"right": {
"type": "LogicalExpression",
"start": 905,
"end": 918,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 25
}
},
"left": {
"type": "Identifier",
"start": 905,
"end": 912,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 19
},
"identifierName": "options"
},
"name": "options"
},
"operator": "||",
"right": {
"type": "ObjectExpression",
"start": 916,
"end": 918,
"loc": {
"start": {
"line": 31,
"column": 23
},
"end": {
"line": 31,
"column": 25
}
},
"properties": []
}
}
},
"trailingComments": [
{
"type": "CommentBlock",
"value": " jshint validthis:true ",
"start": 923,
"end": 950,
"loc": {
"start": {
"line": 33,
"column": 2
},
"end": {
"line": 33,
"column": 29
}
}
}
]
},
{
"type": "ReturnStatement",
"start": 953,
"end": 1317,
"loc": {
"start": {
"line": 34,
"column": 2
},
"end": {
"line": 41,
"column": 5
}
},
"argument": {
"type": "CallExpression",
"start": 960,
"end": 1316,
"loc": {
"start": {
"line": 34,
"column": 9
},
"end": {
"line": 41,
"column": 4
}
},
"callee": {
"type": "MemberExpression",
"start": 960,
"end": 1003,
"loc": {
"start": {
"line": 34,
"column": 9
},
"end": {
"line": 34,
"column": 52
}
},
"object": {
"type": "CallExpression",
"start": 960,
"end": 998,
"loc": {
"start": {
"line": 34,
"column": 9
},
"end": {
"line": 34,
"column": 47
}
},
"callee": {
"type": "MemberExpression",
"start": 960,
"end": 978,
"loc": {
"start": {
"line": 34,
"column": 9
},
"end": {
"line": 34,
"column": 27
}
},
"object": {
"type": "ThisExpression",
"start": 960,
"end": 964,
"loc": {
"start": {
"line": 34,
"column": 9
},
"end": {
"line": 34,
"column": 13
}
},
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 965,
"end": 978,
"loc": {
"start": {
"line": 34,
"column": 14
},
"end": {
"line": 34,
"column": 27
},
"identifierName": "describeTable"
},
"name": "describeTable"
},
"computed": false,
"leadingComments": null
},
"arguments": [
{
"type": "Identifier",
"start": 979,
"end": 988,
"loc": {
"start": {
"line": 34,
"column": 28
},
"end": {
"line": 34,
"column": 37
},
"identifierName": "tableName"
},
"name": "tableName"
},
{
"type": "Identifier",
"start": 990,
"end": 997,
"loc": {
"start": {
"line": 34,
"column": 39
},
"end": {
"line": 34,
"column": 46
},
"identifierName": "options"
},
"name": "options"
}
],
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 999,
"end": 1003,
"loc": {
"start": {
"line": 34,
"column": 48
},
"end": {
"line": 34,
"column": 52
},
"identifierName": "then"
},
"name": "then"
},
"computed": false,
"leadingComments": null
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 1004,
"end": 1315,
"loc": {
"start": {
"line": 34,
"column": 53
},
"end": {
"line": 41,
"column": 3
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1004,
"end": 1010,
"loc": {
"start": {
"line": 34,
"column": 53
},
"end": {
"line": 34,
"column": 59
},
"identifierName": "fields"
},
"name": "fields"
}
],
"body": {
"type": "BlockStatement",
"start": 1014,
"end": 1315,
"loc": {
"start": {
"line": 34,
"column": 63
},
"end": {
"line": 41,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 1020,
"end": 1049,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 35,
"column": 33
}
},
"expression": {
"type": "UnaryExpression",
"start": 1020,
"end": 1048,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 35,
"column": 32
}
},
"operator": "delete",
"prefix": true,
"argument": {
"type": "MemberExpression",
"start": 1027,
"end": 1048,
"loc": {
"start": {
"line": 35,
"column": 11
},
"end": {
"line": 35,
"column": 32
}
},
"object": {
"type": "Identifier",
"start": 1027,
"end": 1033,
"loc": {
"start": {
"line": 35,
"column": 11
},
"end": {
"line": 35,
"column": 17
},
"identifierName": "fields"
},
"name": "fields"
},
"property": {
"type": "Identifier",
"start": 1034,
"end": 1047,
"loc": {
"start": {
"line": 35,
"column": 18
},
"end": {
"line": 35,
"column": 31
},
"identifierName": "attributeName"
},
"name": "attributeName"
},
"computed": true
},
"extra": {
"parenthesizedArgument": false
}
}
},
{
"type": "VariableDeclaration",
"start": 1055,
"end": 1124,
"loc": {
"start": {
"line": 37,
"column": 4
},
"end": {
"line": 37,
"column": 73
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1061,
"end": 1123,
"loc": {
"start": {
"line": 37,
"column": 10
},
"end": {
"line": 37,
"column": 72
}
},
"id": {
"type": "Identifier",
"start": 1061,
"end": 1064,
"loc": {
"start": {
"line": 37,
"column": 10
},
"end": {
"line": 37,
"column": 13
},
"identifierName": "sql"
},
"name": "sql"
},
"init": {
"type": "CallExpression",
"start": 1067,
"end": 1123,
"loc": {
"start": {
"line": 37,
"column": 16
},
"end": {
"line": 37,
"column": 72
}
},
"callee": {
"type": "MemberExpression",
"start": 1067,
"end": 1104,
"loc": {
"start": {
"line": 37,
"column": 16
},
"end": {
"line": 37,
"column": 53
}
},
"object": {
"type": "MemberExpression",
"start": 1067,
"end": 1086,
"loc": {
"start": {
"line": 37,
"column": 16
},
"end": {
"line": 37,
"column": 35
}
},
"object": {
"type": "ThisExpression",
"start": 1067,
"end": 1071,
"loc": {
"start": {
"line": 37,
"column": 16
},
"end": {
"line": 37,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 1072,
"end": 1086,
"loc": {
"start": {
"line": 37,
"column": 21
},
"end": {
"line": 37,
"column": 35
},
"identifierName": "QueryGenerator"
},
"name": "QueryGenerator"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 1087,
"end": 1104,
"loc": {
"start": {
"line": 37,
"column": 36
},
"end": {
"line": 37,
"column": 53
},
"identifierName": "removeColumnQuery"
},
"name": "removeColumnQuery"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1105,
"end": 1114,
"loc": {
"start": {
"line": 37,
"column": 54
},
"end": {
"line": 37,
"column": 63
},
"identifierName": "tableName"
},
"name": "tableName"
},
{
"type": "Identifier",
"start": 1116,
"end": 1122,
"loc": {
"start": {
"line": 37,
"column": 65
},
"end": {
"line": 37,
"column": 71
},
"identifierName": "fields"
},
"name": "fields"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 1129,
"end": 1185,
"loc": {
"start": {
"line": 38,
"column": 4
},
"end": {
"line": 38,
"column": 60
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1135,
"end": 1184,
"loc": {
"start": {
"line": 38,
"column": 10
},
"end": {
"line": 38,
"column": 59
}
},
"id": {
"type": "Identifier",
"start": 1135,
"end": 1145,
"loc": {
"start": {
"line": 38,
"column": 10
},
"end": {
"line": 38,
"column": 20
},
"identifierName": "subQueries"
},
"name": "subQueries"
},
"init": {
"type": "CallExpression",
"start": 1148,
"end": 1184,
"loc": {
"start": {
"line": 38,
"column": 23
},
"end": {
"line": 38,
"column": 59
}
},
"callee": {
"type": "MemberExpression",
"start": 1148,
"end": 1169,
"loc": {
"start": {
"line": 38,
"column": 23
},
"end": {
"line": 38,
"column": 44
}
},
"object": {
"type": "CallExpression",
"start": 1148,
"end": 1162,
"loc": {
"start": {
"line": 38,
"column": 23
},
"end": {
"line": 38,
"column": 37
}
},
"callee": {
"type": "MemberExpression",
"start": 1148,
"end": 1157,
"loc": {
"start": {
"line": 38,
"column": 23
},
"end": {
"line": 38,
"column": 32
}
},
"object": {
"type": "Identifier",
"start": 1148,
"end": 1151,
"loc": {
"start": {
"line": 38,
"column": 23
},
"end": {
"line": 38,
"column": 26
},
"identifierName": "sql"
},
"name": "sql"
},
"property": {
"type": "Identifier",
"start": 1152,
"end": 1157,
"loc": {
"start": {
"line": 38,
"column": 27
},
"end": {
"line": 38,
"column": 32
},
"identifierName": "split"
},
"name": "split"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 1158,
"end": 1161,
"loc": {
"start": {
"line": 38,
"column": 33
},
"end": {
"line": 38,
"column": 36
}
},
"extra": {
"rawValue": ";",
"raw": "';'"
},
"value": ";"
}
]
},
"property": {
"type": "Identifier",
"start": 1163,
"end": 1169,
"loc": {
"start": {
"line": 38,
"column": 38
},
"end": {
"line": 38,
"column": 44
},
"identifierName": "filter"
},
"name": "filter"
},
"computed": false
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 1170,
"end": 1183,
"loc": {
"start": {
"line": 38,
"column": 45
},
"end": {
"line": 38,
"column": 58
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1170,
"end": 1171,
"loc": {
"start": {
"line": 38,
"column": 45
},
"end": {
"line": 38,
"column": 46
},
"identifierName": "q"
},
"name": "q"
}
],
"body": {
"type": "BinaryExpression",
"start": 1175,
"end": 1183,
"loc": {
"start": {
"line": 38,
"column": 50
},
"end": {
"line": 38,
"column": 58
}
},
"left": {
"type": "Identifier",
"start": 1175,
"end": 1176,
"loc": {
"start": {
"line": 38,
"column": 50
},
"end": {
"line": 38,
"column": 51
},
"identifierName": "q"
},
"name": "q"
},
"operator": "!==",
"right": {
"type": "StringLiteral",
"start": 1181,
"end": 1183,
"loc": {
"start": {
"line": 38,
"column": 56
},
"end": {
"line": 38,
"column": 58
}
},
"extra": {
"rawValue": "",
"raw": "''"
},
"value": ""
}
}
}
]
}
}
],
"kind": "const"
},
{
"type": "ReturnStatement",
"start": 1191,
"end": 1311,
"loc": {
"start": {
"line": 40,
"column": 4
},
"end": {
"line": 40,
"column": 124
}
},
"argument": {
"type": "CallExpression",
"start": 1198,
"end": 1310,
"loc": {
"start": {
"line": 40,
"column": 11
},
"end": {
"line": 40,
"column": 123
}
},
"callee": {
"type": "MemberExpression",
"start": 1198,
"end": 1210,
"loc": {
"start": {
"line": 40,
"column": 11
},
"end": {
"line": 40,
"column": 23
}
},
"object": {
"type": "Identifier",
"start": 1198,
"end": 1205,
"loc": {
"start": {
"line": 40,
"column": 11
},
"end": {
"line": 40,
"column": 18
},
"identifierName": "Promise"
},
"name": "Promise"
},
"property": {
"type": "Identifier",
"start": 1206,
"end": 1210,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 23
},
"identifierName": "each"
},
"name": "each"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1211,
"end": 1221,
"loc": {
"start": {
"line": 40,
"column": 24
},
"end": {
"line": 40,
"column": 34
},
"identifierName": "subQueries"
},
"name": "subQueries"
},
{
"type": "Arrow