UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,505 lines (1,504 loc) 5.16 MB
{ "type": "File", "start": 0, "end": 28039, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 862, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 28039, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 862, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 34, "end": 260, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 8, "column": 31 } }, "declarations": [ { "type": "VariableDeclarator", "start": 38, "end": 68, "loc": { "start": { "line": 4, "column": 4 }, "end": { "line": 4, "column": 34 } }, "id": { "type": "Identifier", "start": 38, "end": 43, "loc": { "start": { "line": 4, "column": 4 }, "end": { "line": 4, "column": 9 }, "identifierName": "Utils" }, "name": "Utils", "leadingComments": null }, "init": { "type": "CallExpression", "start": 46, "end": 68, "loc": { "start": { "line": 4, "column": 12 }, "end": { "line": 4, "column": 34 } }, "callee": { "type": "Identifier", "start": 46, "end": 53, "loc": { "start": { "line": 4, "column": 12 }, "end": { "line": 4, "column": 19 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 54, "end": 67, "loc": { "start": { "line": 4, "column": 20 }, "end": { "line": 4, "column": 33 } }, "extra": { "rawValue": "../../utils", "raw": "'../../utils'" }, "value": "../../utils" } ] }, "leadingComments": null }, { "type": "VariableDeclarator", "start": 73, "end": 112, "loc": { "start": { "line": 5, "column": 4 }, "end": { "line": 5, "column": 43 } }, "id": { "type": "Identifier", "start": 73, "end": 82, "loc": { "start": { "line": 5, "column": 4 }, "end": { "line": 5, "column": 13 }, "identifierName": "DataTypes" }, "name": "DataTypes" }, "init": { "type": "CallExpression", "start": 85, "end": 112, "loc": { "start": { "line": 5, "column": 16 }, "end": { "line": 5, "column": 43 } }, "callee": { "type": "Identifier", "start": 85, "end": 92, "loc": { "start": { "line": 5, "column": 16 }, "end": { "line": 5, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 93, "end": 111, "loc": { "start": { "line": 5, "column": 24 }, "end": { "line": 5, "column": 42 } }, "extra": { "rawValue": "../../data-types", "raw": "'../../data-types'" }, "value": "../../data-types" } ] } }, { "type": "VariableDeclarator", "start": 117, "end": 180, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 6, "column": 67 } }, "id": { "type": "Identifier", "start": 117, "end": 139, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 6, "column": 26 }, "identifierName": "AbstractQueryGenerator" }, "name": "AbstractQueryGenerator" }, "init": { "type": "CallExpression", "start": 142, "end": 180, "loc": { "start": { "line": 6, "column": 29 }, "end": { "line": 6, "column": 67 } }, "callee": { "type": "Identifier", "start": 142, "end": 149, "loc": { "start": { "line": 6, "column": 29 }, "end": { "line": 6, "column": 36 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 150, "end": 179, "loc": { "start": { "line": 6, "column": 37 }, "end": { "line": 6, "column": 66 } }, "extra": { "rawValue": "../abstract/query-generator", "raw": "'../abstract/query-generator'" }, "value": "../abstract/query-generator" } ] } }, { "type": "VariableDeclarator", "start": 185, "end": 228, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 47 } }, "id": { "type": "Identifier", "start": 185, "end": 196, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 15 }, "identifierName": "randomBytes" }, "name": "randomBytes" }, "init": { "type": "MemberExpression", "start": 199, "end": 228, "loc": { "start": { "line": 7, "column": 18 }, "end": { "line": 7, "column": 47 } }, "object": { "type": "CallExpression", "start": 199, "end": 216, "loc": { "start": { "line": 7, "column": 18 }, "end": { "line": 7, "column": 35 } }, "callee": { "type": "Identifier", "start": 199, "end": 206, "loc": { "start": { "line": 7, "column": 18 }, "end": { "line": 7, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 207, "end": 215, "loc": { "start": { "line": 7, "column": 26 }, "end": { "line": 7, "column": 34 } }, "extra": { "rawValue": "crypto", "raw": "'crypto'" }, "value": "crypto" } ] }, "property": { "type": "Identifier", "start": 217, "end": 228, "loc": { "start": { "line": 7, "column": 36 }, "end": { "line": 7, "column": 47 }, "identifierName": "randomBytes" }, "name": "randomBytes" }, "computed": false } }, { "type": "VariableDeclarator", "start": 233, "end": 259, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 30 } }, "id": { "type": "Identifier", "start": 233, "end": 239, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 10 }, "identifierName": "semver" }, "name": "semver" }, "init": { "type": "CallExpression", "start": 242, "end": 259, "loc": { "start": { "line": 8, "column": 13 }, "end": { "line": 8, "column": 30 } }, "callee": { "type": "Identifier", "start": 242, "end": 249, "loc": { "start": { "line": 8, "column": 13 }, "end": { "line": 8, "column": 20 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 250, "end": 258, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 8, "column": 29 } }, "extra": { "rawValue": "semver", "raw": "'semver'" }, "value": "semver" } ] } } ], "kind": "var", "leadingComments": [ { "type": "CommentBlock", "value": " jshint -W110 ", "start": 15, "end": 33, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 18 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": " istanbul ignore next ", "start": 262, "end": 288, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 26 } } } ] }, { "type": "VariableDeclaration", "start": 289, "end": 446, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 13, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 293, "end": 445, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 13, "column": 1 } }, "id": { "type": "Identifier", "start": 293, "end": 313, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 24 }, "identifierName": "throwMethodUndefined" }, "name": "throwMethodUndefined", "leadingComments": null }, "init": { "type": "FunctionExpression", "start": 316, "end": 445, "loc": { "start": { "line": 11, "column": 27 }, "end": { "line": 13, "column": 1 } }, "id": { "type": "Identifier", "start": 293, "end": 313, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 24 }, "identifierName": "throwMethodUndefined" }, "name": "throwMethodUndefined", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 325, "end": 335, "loc": { "start": { "line": 11, "column": 36 }, "end": { "line": 11, "column": 46 }, "identifierName": "methodName" }, "name": "methodName" } ], "body": { "type": "BlockStatement", "start": 337, "end": 445, "loc": { "start": { "line": 11, "column": 48 }, "end": { "line": 13, "column": 1 } }, "body": [ { "type": "ThrowStatement", "start": 341, "end": 443, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 104 } }, "argument": { "type": "NewExpression", "start": 347, "end": 442, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 103 } }, "callee": { "type": "Identifier", "start": 351, "end": 356, "loc": { "start": { "line": 12, "column": 12 }, "end": { "line": 12, "column": 17 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "BinaryExpression", "start": 357, "end": 441, "loc": { "start": { "line": 12, "column": 18 }, "end": { "line": 12, "column": 102 } }, "left": { "type": "BinaryExpression", "start": 357, "end": 384, "loc": { "start": { "line": 12, "column": 18 }, "end": { "line": 12, "column": 45 } }, "left": { "type": "StringLiteral", "start": 357, "end": 371, "loc": { "start": { "line": 12, "column": 18 }, "end": { "line": 12, "column": 32 } }, "extra": { "rawValue": "The method \"", "raw": "'The method \"'" }, "value": "The method \"" }, "operator": "+", "right": { "type": "Identifier", "start": 374, "end": 384, "loc": { "start": { "line": 12, "column": 35 }, "end": { "line": 12, "column": 45 }, "identifierName": "methodName" }, "name": "methodName" } }, "operator": "+", "right": { "type": "StringLiteral", "start": 387, "end": 441, "loc": { "start": { "line": 12, "column": 48 }, "end": { "line": 12, "column": 102 } }, "extra": { "rawValue": "\" is not defined! Please add it to your sql dialect.", "raw": "'\" is not defined! Please add it to your sql dialect.'" }, "value": "\" is not defined! Please add it to your sql dialect." } } ] } } ], "directives": [] } }, "leadingComments": null } ], "kind": "var", "leadingComments": [ { "type": "CommentBlock", "value": " istanbul ignore next ", "start": 262, "end": 288, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 26 } } } ] }, { "type": "VariableDeclaration", "start": 448, "end": 27878, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 854, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 452, "end": 27877, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 854, "column": 1 } }, "id": { "type": "Identifier", "start": 452, "end": 466, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 18 }, "identifierName": "QueryGenerator" }, "name": "QueryGenerator" }, "init": { "type": "ObjectExpression", "start": 469, "end": 27877, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 854, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 499, "end": 532, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 499, "end": 508, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 11 }, "identifierName": "__proto__" }, "name": "__proto__", "leadingComments": null }, "value": { "type": "Identifier", "start": 510, "end": 532, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 35 }, "identifierName": "AbstractQueryGenerator" }, "name": "AbstractQueryGenerator" }, "leadingComments": [ { "type": "CommentBlock", "value": " jshint proto:true ", "start": 473, "end": 496, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 25 } } } ] }, { "type": "ObjectProperty", "start": 536, "end": 547, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 13 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 536, "end": 543, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 9 }, "identifierName": "options" }, "name": "options" }, "value": { "type": "ObjectExpression", "start": 545, "end": 547, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 18, "column": 13 } }, "properties": [] } }, { "type": "ObjectProperty", "start": 551, "end": 567, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 551, "end": 558, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 9 }, "identifierName": "dialect" }, "name": "dialect" }, "value": { "type": "StringLiteral", "start": 560, "end": 567, "loc": { "start": { "line": 19, "column": 11 }, "end": { "line": 19, "column": 18 } }, "extra": { "rawValue": "mssql", "raw": "'mssql'" }, "value": "mssql" } }, { "type": "ObjectMethod", "start": 572, "end": 892, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 32, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 572, "end": 584, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 21, "column": 14 }, "identifierName": "createSchema" }, "name": "createSchema" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 585, "end": 591, "loc": { "start": { "line": 21, "column": 15 }, "end": { "line": 21, "column": 21 }, "identifierName": "schema" }, "name": "schema" } ], "body": { "type": "BlockStatement", "start": 593, "end": 892, "loc": { "start": { "line": 21, "column": 23 }, "end": { "line": 32, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 599, "end": 888, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 31, "column": 16 } }, "argument": { "type": "CallExpression", "start": 606, "end": 887, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 31, "column": 15 } }, "callee": { "type": "MemberExpression", "start": 606, "end": 882, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 31, "column": 10 } }, "object": { "type": "ArrayExpression", "start": 606, "end": 877, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 31, "column": 5 } }, "elements": [ { "type": "StringLiteral", "start": 614, "end": 649, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 41 } }, "extra": { "rawValue": "IF NOT EXISTS (SELECT schema_name", "raw": "'IF NOT EXISTS (SELECT schema_name'" }, "value": "IF NOT EXISTS (SELECT schema_name" }, { "type": "StringLiteral", "start": 657, "end": 691, "loc": { "start": { "line": 24, "column": 6 }, "end": { "line": 24, "column": 40 } }, "extra": { "rawValue": "FROM information_schema.schemata", "raw": "'FROM information_schema.schemata'" }, "value": "FROM information_schema.schemata" }, { "type": "StringLiteral", "start": 699, "end": 720, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 27 } }, "extra": { "rawValue": "WHERE schema_name =", "raw": "'WHERE schema_name ='" }, "value": "WHERE schema_name =" }, { "type": "CallExpression", "start": 722, "end": 745, "loc": { "start": { "line": 25, "column": 29 }, "end": { "line": 25, "column": 52 } }, "callee": { "type": "Identifier", "start": 722, "end": 737, "loc": { "start": { "line": 25, "column": 29 }, "end": { "line": 25, "column": 44 }, "identifierName": "wrapSingleQuote" }, "name": "wrapSingleQuote" }, "arguments": [ { "type": "Identifier", "start": 738, "end": 744, "loc": { "start": { "line": 25, "column": 45 }, "end": { "line": 25, "column": 51 }, "identifierName": "schema" }, "name": "schema" } ] }, { "type": "StringLiteral", "start": 747, "end": 750, "loc": { "start": { "line": 25, "column": 54 }, "end": { "line": 25, "column": 57 } }, "extra": { "rawValue": ")", "raw": "')'" }, "value": ")" }, { "type": "StringLiteral", "start": 758, "end": 765, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 13 } }, "extra": { "rawValue": "BEGIN", "raw": "'BEGIN'" }, "value": "BEGIN" }, { "type": "StringLiteral", "start": 773, "end": 809, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 42 } }, "extra": { "rawValue": "EXEC sp_executesql N'CREATE SCHEMA", "raw": "\"EXEC sp_executesql N'CREATE SCHEMA\"" }, "value": "EXEC sp_executesql N'CREATE SCHEMA" }, { "type": "CallExpression", "start": 817, "end": 845, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 28, "column": 34 } }, "callee": { "type": "MemberExpression", "start": 817, "end": 837, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 28, "column": 26 } }, "object": { "type": "ThisExpression", "start": 817, "end": 821, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 28, "column": 10 } } }, "property": { "type": "Identifier", "start": 822, "end": 837, "loc": { "start": { "line": 28, "column": 11 }, "end": { "line": 28, "column": 26 }, "identifierName": "quoteIdentifier" }, "name": "quoteIdentifier" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 838, "end": 844, "loc": { "start": { "line": 28, "column": 27 }, "end": { "line": 28, "column": 33 }, "identifierName": "schema" }, "name": "schema" } ] }, { "type": "StringLiteral", "start": 853, "end": 857, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 10 } }, "extra": { "rawValue": ";'", "raw": "\";'\"" }, "value": ";'" }, { "type": "StringLiteral", "start": 865, "end": 871, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 30, "column": 12 } }, "extra": { "rawValue": "END;", "raw": "'END;'" }, "value": "END;" } ] }, "property": { "type": "Identifier", "start": 878, "end": 882, "loc": { "start": { "line": 31, "column": 6 }, "end": { "line": 31,