UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,660 lines (1,659 loc) 1.34 MB
{ "type": "File", "start": 0, "end": 7289, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 192, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 7289, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 192, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 91, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 76 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 90, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 75 } }, "id": { "type": "Identifier", "start": 21, "end": 46, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 31 }, "identifierName": "AbstractConnectionManager" }, "name": "AbstractConnectionManager" }, "init": { "type": "CallExpression", "start": 49, "end": 90, "loc": { "start": { "line": 3, "column": 34 }, "end": { "line": 3, "column": 75 } }, "callee": { "type": "Identifier", "start": 49, "end": 56, "loc": { "start": { "line": 3, "column": 34 }, "end": { "line": 3, "column": 41 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 57, "end": 89, "loc": { "start": { "line": 3, "column": 42 }, "end": { "line": 3, "column": 74 } }, "extra": { "rawValue": "../abstract/connection-manager", "raw": "'../abstract/connection-manager'" }, "value": "../abstract/connection-manager" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 92, "end": 129, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 98, "end": 128, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 36 } }, "id": { "type": "Identifier", "start": 98, "end": 103, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 11 }, "identifierName": "Utils" }, "name": "Utils" }, "init": { "type": "CallExpression", "start": 106, "end": 128, "loc": { "start": { "line": 4, "column": 14 }, "end": { "line": 4, "column": 36 } }, "callee": { "type": "Identifier", "start": 106, "end": 113, "loc": { "start": { "line": 4, "column": 14 }, "end": { "line": 4, "column": 21 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 114, "end": 127, "loc": { "start": { "line": 4, "column": 22 }, "end": { "line": 4, "column": 35 } }, "extra": { "rawValue": "../../utils", "raw": "'../../utils'" }, "value": "../../utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 130, "end": 192, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 62 } }, "declarations": [ { "type": "VariableDeclarator", "start": 136, "end": 191, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 61 } }, "id": { "type": "Identifier", "start": 136, "end": 141, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 11 }, "identifierName": "debug" }, "name": "debug" }, "init": { "type": "CallExpression", "start": 144, "end": 191, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 61 } }, "callee": { "type": "MemberExpression", "start": 144, "end": 174, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 44 } }, "object": { "type": "CallExpression", "start": 144, "end": 161, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 31 } }, "callee": { "type": "MemberExpression", "start": 144, "end": 159, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 29 } }, "object": { "type": "Identifier", "start": 144, "end": 149, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 19 }, "identifierName": "Utils" }, "name": "Utils" }, "property": { "type": "Identifier", "start": 150, "end": 159, "loc": { "start": { "line": 5, "column": 20 }, "end": { "line": 5, "column": 29 }, "identifierName": "getLogger" }, "name": "getLogger" }, "computed": false }, "arguments": [] }, "property": { "type": "Identifier", "start": 162, "end": 174, "loc": { "start": { "line": 5, "column": 32 }, "end": { "line": 5, "column": 44 }, "identifierName": "debugContext" }, "name": "debugContext" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 175, "end": 190, "loc": { "start": { "line": 5, "column": 45 }, "end": { "line": 5, "column": 60 } }, "extra": { "rawValue": "connection:pg", "raw": "'connection:pg'" }, "value": "connection:pg" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 193, "end": 234, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 41 } }, "declarations": [ { "type": "VariableDeclarator", "start": 199, "end": 233, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 40 } }, "id": { "type": "Identifier", "start": 199, "end": 206, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 13 }, "identifierName": "Promise" }, "name": "Promise" }, "init": { "type": "CallExpression", "start": 209, "end": 233, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 40 } }, "callee": { "type": "Identifier", "start": 209, "end": 216, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 217, "end": 232, "loc": { "start": { "line": 6, "column": 24 }, "end": { "line": 6, "column": 39 } }, "extra": { "rawValue": "../../promise", "raw": "'../../promise'" }, "value": "../../promise" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 235, "end": 283, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 48 } }, "declarations": [ { "type": "VariableDeclarator", "start": 241, "end": 282, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 47 } }, "id": { "type": "Identifier", "start": 241, "end": 256, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 21 }, "identifierName": "sequelizeErrors" }, "name": "sequelizeErrors" }, "init": { "type": "CallExpression", "start": 259, "end": 282, "loc": { "start": { "line": 7, "column": 24 }, "end": { "line": 7, "column": 47 } }, "callee": { "type": "Identifier", "start": 259, "end": 266, "loc": { "start": { "line": 7, "column": 24 }, "end": { "line": 7, "column": 31 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 267, "end": 281, "loc": { "start": { "line": 7, "column": 32 }, "end": { "line": 7, "column": 46 } }, "extra": { "rawValue": "../../errors", "raw": "'../../errors'" }, "value": "../../errors" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 284, "end": 317, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 290, "end": 316, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 32 } }, "id": { "type": "Identifier", "start": 290, "end": 296, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 12 }, "identifierName": "semver" }, "name": "semver" }, "init": { "type": "CallExpression", "start": 299, "end": 316, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 8, "column": 32 } }, "callee": { "type": "Identifier", "start": 299, "end": 306, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 8, "column": 22 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 307, "end": 315, "loc": { "start": { "line": 8, "column": 23 }, "end": { "line": 8, "column": 31 } }, "extra": { "rawValue": "semver", "raw": "'semver'" }, "value": "semver" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 318, "end": 364, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 46 } }, "declarations": [ { "type": "VariableDeclarator", "start": 324, "end": 363, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 45 } }, "id": { "type": "Identifier", "start": 324, "end": 333, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 15 }, "identifierName": "dataTypes" }, "name": "dataTypes" }, "init": { "type": "CallExpression", "start": 336, "end": 363, "loc": { "start": { "line": 9, "column": 18 }, "end": { "line": 9, "column": 45 } }, "callee": { "type": "Identifier", "start": 336, "end": 343, "loc": { "start": { "line": 9, "column": 18 }, "end": { "line": 9, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 344, "end": 362, "loc": { "start": { "line": 9, "column": 26 }, "end": { "line": 9, "column": 44 } }, "extra": { "rawValue": "../../data-types", "raw": "'../../data-types'" }, "value": "../../data-types" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 365, "end": 407, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 371, "end": 406, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 41 } }, "id": { "type": "Identifier", "start": 371, "end": 377, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 12 }, "identifierName": "moment" }, "name": "moment" }, "init": { "type": "CallExpression", "start": 380, "end": 406, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 10, "column": 41 } }, "callee": { "type": "Identifier", "start": 380, "end": 387, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 10, "column": 22 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 388, "end": 405, "loc": { "start": { "line": 10, "column": 23 }, "end": { "line": 10, "column": 40 } }, "extra": { "rawValue": "moment-timezone", "raw": "'moment-timezone'" }, "value": "moment-timezone" } ] } } ], "kind": "const" }, { "type": "ClassDeclaration", "start": 409, "end": 7070, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 185, "column": 1 } }, "id": { "type": "Identifier", "start": 415, "end": 432, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 23 }, "identifierName": "ConnectionManager" }, "name": "ConnectionManager" }, "superClass": { "type": "Identifier", "start": 441, "end": 466, "loc": { "start": { "line": 12, "column": 32 }, "end": { "line": 12, "column": 57 }, "identifierName": "AbstractConnectionManager" }, "name": "AbstractConnectionManager" }, "body": { "type": "ClassBody", "start": 467, "end": 7070, "loc": { "start": { "line": 12, "column": 58 }, "end": { "line": 185, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 471, "end": 1157, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 34, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 471, "end": 482, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 483, "end": 490, "loc": { "start": { "line": 13, "column": 14 }, "end": { "line": 13, "column": 21 }, "identifierName": "dialect" }, "name": "dialect" }, { "type": "Identifier", "start": 492, "end": 501, "loc": { "start": { "line": 13, "column": 23 }, "end": { "line": 13, "column": 32 }, "identifierName": "sequelize" }, "name": "sequelize" } ], "body": { "type": "BlockStatement", "start": 503, "end": 1157, "loc": { "start": { "line": 13, "column": 34 }, "end": { "line": 34, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 509, "end": 535, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 30 } }, "expression": { "type": "CallExpression", "start": 509, "end": 534, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 29 } }, "callee": { "type": "Super", "start": 509, "end": 514, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 9 } } }, "arguments": [ { "type": "Identifier", "start": 515, "end": 522, "loc": { "start": { "line": 14, "column": 10 }, "end": { "line": 14, "column": 17 }, "identifierName": "dialect" }, "name": "dialect" }, { "type": "Identifier", "start": 524, "end": 533, "loc": { "start": { "line": 14, "column": 19 }, "end": { "line": 14, "column": 28 }, "identifierName": "sequelize" }, "name": "sequelize" } ] } }, { "type": "ExpressionStatement", "start": 541, "end": 568, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 541, "end": 567, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 541, "end": 555, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 18 } }, "object": { "type": "ThisExpression", "start": 541, "end": 545, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 8 } } }, "property": { "type": "Identifier", "start": 546, "end": 555, "loc": { "start": { "line": 16, "column": 9 }, "end": { "line": 16, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "right": { "type": "Identifier", "start": 558, "end": 567, "loc": { "start": { "line": 16, "column": 21 }, "end": { "line": 16, "column": 30 }, "identifierName": "sequelize" }, "name": "sequelize" } } }, { "type": "ExpressionStatement", "start": 573, "end": 637, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 68 } }, "expression": { "type": "AssignmentExpression", "start": 573, "end": 636, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 67 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 573, "end": 599, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 30 } }, "object": { "type": "MemberExpression", "start": 573, "end": 594, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 25 } }, "object": { "type": "MemberExpression", "start": 573, "end": 587, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 18 } }, "object": { "type": "ThisExpression", "start": 573, "end": 577, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 8 } } }, "property": { "type": "Identifier", "start": 578, "end": 587, "loc": { "start": { "line": 17, "column": 9 }, "end": { "line": 17, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 588, "end": 594, "loc": { "start": { "line": 17, "column": 19 }, "end": { "line": 17, "column": 25 }, "identifierName": "config" }, "name": "config" }, "computed": false }, "property": { "type": "Identifier", "start": 595, "end": 599, "loc": { "start": { "line": 17, "column": 26 }, "end": { "line": 17, "column": 30 }, "identifierName": "port" }, "name": "port" }, "computed": false }, "right": { "type": "LogicalExpression", "start": 602, "end": 636, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 67 } }, "left": { "type": "MemberExpression", "start": 602, "end": 628, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 59 } }, "object": { "type": "MemberExpression", "start": 602, "end": 623, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 54 } }, "object": { "type": "MemberExpression", "start": 602, "end": 616, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 47 } }, "object": { "type": "ThisExpression", "start": 602, "end": 606, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 37 } } }, "property": { "type": "Identifier", "start": 607, "end": 616, "loc": { "start": { "line": 17, "column": 38 }, "end": { "line": 17, "column": 47 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 617, "end": 623, "loc": { "start": { "line": 17, "column": 48 }, "end": { "line": 17, "column": 54 }, "identifierName": "config" }, "name": "config" }, "computed": false }, "property": { "type": "Identifier", "start": 624, "end": 628, "loc": { "start": { "line": 17, "column": 55 }, "end": { "line": 17, "column": 59 }, "identifierName": "port" }, "name": "port" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 632, "end": 636, "loc": { "start": { "line": 17, "column": 63 }, "end": { "line": 17, "column": 67 } }, "extra": { "rawValue": 5432, "raw": "5432" }, "value": 5432 } } } }, { "type": "TryStatement", "start": 642, "end": 1104, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 31, "column": 5 } }, "block": { "type": "BlockStatement", "start": 646, "end": 898, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 26, "column": 5 } }, "body": [ { "type": "VariableDeclaration", "start": 654, "end": 664, "loc": { "start": { "line": 19, "column": 6 }, "end": { "line": 19, "column": 16 } }, "declarations": [ { "type": "VariableDeclarator", "start": 658, "end": 663, "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 15 } }, "id": { "type": "Identifier", "start": 658, "end": 663, "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 15 }, "identifierName": "pgLib" }, "name": "pgLib" }, "init": null } ], "kind": "let" }, { "type": "IfStatement", "start": 671, "end": 827, "loc": { "start": { "line": 20, "column": 6 }, "end": { "line": 24,