UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,619 lines (1,618 loc) 1.04 MB
{ "type": "File", "start": 0, "end": 6249, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 196, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 6249, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 196, "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": 140, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 48 } }, "declarations": [ { "type": "VariableDeclarator", "start": 98, "end": 139, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 47 } }, "id": { "type": "Identifier", "start": 98, "end": 113, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 21 }, "identifierName": "SequelizeErrors" }, "name": "SequelizeErrors" }, "init": { "type": "CallExpression", "start": 116, "end": 139, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 47 } }, "callee": { "type": "Identifier", "start": 116, "end": 123, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 31 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 124, "end": 138, "loc": { "start": { "line": 4, "column": 32 }, "end": { "line": 4, "column": 46 } }, "extra": { "rawValue": "../../errors", "raw": "'../../errors'" }, "value": "../../errors" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 141, "end": 178, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 147, "end": 177, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 36 } }, "id": { "type": "Identifier", "start": 147, "end": 152, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 11 }, "identifierName": "Utils" }, "name": "Utils" }, "init": { "type": "CallExpression", "start": 155, "end": 177, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 36 } }, "callee": { "type": "Identifier", "start": 155, "end": 162, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 21 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 163, "end": 176, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 35 } }, "extra": { "rawValue": "../../utils", "raw": "'../../utils'" }, "value": "../../utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 179, "end": 231, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 52 } }, "declarations": [ { "type": "VariableDeclarator", "start": 185, "end": 230, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 51 } }, "id": { "type": "Identifier", "start": 185, "end": 194, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 15 }, "identifierName": "DataTypes" }, "name": "DataTypes" }, "init": { "type": "MemberExpression", "start": 197, "end": 230, "loc": { "start": { "line": 6, "column": 18 }, "end": { "line": 6, "column": 51 } }, "object": { "type": "CallExpression", "start": 197, "end": 224, "loc": { "start": { "line": 6, "column": 18 }, "end": { "line": 6, "column": 45 } }, "callee": { "type": "Identifier", "start": 197, "end": 204, "loc": { "start": { "line": 6, "column": 18 }, "end": { "line": 6, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 205, "end": 223, "loc": { "start": { "line": 6, "column": 26 }, "end": { "line": 6, "column": 44 } }, "extra": { "rawValue": "../../data-types", "raw": "'../../data-types'" }, "value": "../../data-types" } ] }, "property": { "type": "Identifier", "start": 225, "end": 230, "loc": { "start": { "line": 6, "column": 46 }, "end": { "line": 6, "column": 51 }, "identifierName": "mysql" }, "name": "mysql" }, "computed": false } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 232, "end": 276, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 44 } }, "declarations": [ { "type": "VariableDeclarator", "start": 238, "end": 275, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 43 } }, "id": { "type": "Identifier", "start": 238, "end": 246, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 14 }, "identifierName": "momentTz" }, "name": "momentTz" }, "init": { "type": "CallExpression", "start": 249, "end": 275, "loc": { "start": { "line": 7, "column": 17 }, "end": { "line": 7, "column": 43 } }, "callee": { "type": "Identifier", "start": 249, "end": 256, "loc": { "start": { "line": 7, "column": 17 }, "end": { "line": 7, "column": 24 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 257, "end": 274, "loc": { "start": { "line": 7, "column": 25 }, "end": { "line": 7, "column": 42 } }, "extra": { "rawValue": "moment-timezone", "raw": "'moment-timezone'" }, "value": "moment-timezone" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 277, "end": 342, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 65 } }, "declarations": [ { "type": "VariableDeclarator", "start": 283, "end": 341, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 64 } }, "id": { "type": "Identifier", "start": 283, "end": 288, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 11 }, "identifierName": "debug" }, "name": "debug" }, "init": { "type": "CallExpression", "start": 291, "end": 341, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 64 } }, "callee": { "type": "MemberExpression", "start": 291, "end": 321, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 44 } }, "object": { "type": "CallExpression", "start": 291, "end": 308, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 31 } }, "callee": { "type": "MemberExpression", "start": 291, "end": 306, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 29 } }, "object": { "type": "Identifier", "start": 291, "end": 296, "loc": { "start": { "line": 8, "column": 14 }, "end": { "line": 8, "column": 19 }, "identifierName": "Utils" }, "name": "Utils" }, "property": { "type": "Identifier", "start": 297, "end": 306, "loc": { "start": { "line": 8, "column": 20 }, "end": { "line": 8, "column": 29 }, "identifierName": "getLogger" }, "name": "getLogger" }, "computed": false }, "arguments": [] }, "property": { "type": "Identifier", "start": 309, "end": 321, "loc": { "start": { "line": 8, "column": 32 }, "end": { "line": 8, "column": 44 }, "identifierName": "debugContext" }, "name": "debugContext" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 322, "end": 340, "loc": { "start": { "line": 8, "column": 45 }, "end": { "line": 8, "column": 63 } }, "extra": { "rawValue": "connection:mysql", "raw": "'connection:mysql'" }, "value": "connection:mysql" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 343, "end": 371, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 349, "end": 370, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 27 } }, "id": { "type": "Identifier", "start": 349, "end": 358, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 15 }, "identifierName": "parserMap" }, "name": "parserMap" }, "init": { "type": "NewExpression", "start": 361, "end": 370, "loc": { "start": { "line": 9, "column": 18 }, "end": { "line": 9, "column": 27 } }, "callee": { "type": "Identifier", "start": 365, "end": 368, "loc": { "start": { "line": 9, "column": 22 }, "end": { "line": 9, "column": 25 }, "identifierName": "Map" }, "name": "Map" }, "arguments": [] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\n * MySQL Connection Managger\n *\n * Get connections, validate and disconnect them.\n * AbstractConnectionManager pooling use it to handle MySQL specific connections\n * Use https://github.com/sidorares/node-mysql2 to connect with MySQL server\n *\n * @extends AbstractConnectionManager\n * @return Class<ConnectionManager>\n * @private\n ", "start": 373, "end": 709, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 21, "column": 3 } } } ] }, { "type": "ClassDeclaration", "start": 711, "end": 6030, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 189, "column": 1 } }, "id": { "type": "Identifier", "start": 717, "end": 734, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 23 }, "identifierName": "ConnectionManager" }, "name": "ConnectionManager", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 743, "end": 768, "loc": { "start": { "line": 23, "column": 32 }, "end": { "line": 23, "column": 57 }, "identifierName": "AbstractConnectionManager" }, "name": "AbstractConnectionManager" }, "body": { "type": "ClassBody", "start": 769, "end": 6030, "loc": { "start": { "line": 23, "column": 58 }, "end": { "line": 189, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 773, "end": 1329, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 43, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 773, "end": 784, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 785, "end": 792, "loc": { "start": { "line": 24, "column": 14 }, "end": { "line": 24, "column": 21 }, "identifierName": "dialect" }, "name": "dialect" }, { "type": "Identifier", "start": 794, "end": 803, "loc": { "start": { "line": 24, "column": 23 }, "end": { "line": 24, "column": 32 }, "identifierName": "sequelize" }, "name": "sequelize" } ], "body": { "type": "BlockStatement", "start": 805, "end": 1329, "loc": { "start": { "line": 24, "column": 34 }, "end": { "line": 43, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 811, "end": 837, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 30 } }, "expression": { "type": "CallExpression", "start": 811, "end": 836, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 29 } }, "callee": { "type": "Super", "start": 811, "end": 816, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 9 } } }, "arguments": [ { "type": "Identifier", "start": 817, "end": 824, "loc": { "start": { "line": 25, "column": 10 }, "end": { "line": 25, "column": 17 }, "identifierName": "dialect" }, "name": "dialect" }, { "type": "Identifier", "start": 826, "end": 835, "loc": { "start": { "line": 25, "column": 19 }, "end": { "line": 25, "column": 28 }, "identifierName": "sequelize" }, "name": "sequelize" } ] } }, { "type": "ExpressionStatement", "start": 843, "end": 870, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 843, "end": 869, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 843, "end": 857, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 18 } }, "object": { "type": "ThisExpression", "start": 843, "end": 847, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 8 } } }, "property": { "type": "Identifier", "start": 848, "end": 857, "loc": { "start": { "line": 27, "column": 9 }, "end": { "line": 27, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "right": { "type": "Identifier", "start": 860, "end": 869, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 30 }, "identifierName": "sequelize" }, "name": "sequelize" } } }, { "type": "ExpressionStatement", "start": 875, "end": 939, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 68 } }, "expression": { "type": "AssignmentExpression", "start": 875, "end": 938, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 67 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 875, "end": 901, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 30 } }, "object": { "type": "MemberExpression", "start": 875, "end": 896, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 25 } }, "object": { "type": "MemberExpression", "start": 875, "end": 889, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 18 } }, "object": { "type": "ThisExpression", "start": 875, "end": 879, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 8 } } }, "property": { "type": "Identifier", "start": 880, "end": 889, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 890, "end": 896, "loc": { "start": { "line": 28, "column": 19 }, "end": { "line": 28, "column": 25 }, "identifierName": "config" }, "name": "config" }, "computed": false }, "property": { "type": "Identifier", "start": 897, "end": 901, "loc": { "start": { "line": 28, "column": 26 }, "end": { "line": 28, "column": 30 }, "identifierName": "port" }, "name": "port" }, "computed": false }, "right": { "type": "LogicalExpression", "start": 904, "end": 938, "loc": { "start": { "line": 28, "column": 33 }, "end": { "line": 28, "column": 67 } }, "left": { "type": "MemberExpression", "start": 904, "end": 930, "loc": { "start": { "line": 28, "column": 33 }, "end": { "line": 28, "column": 59 } }, "object": { "type": "MemberExpression", "start": 904, "end": 925, "loc": { "start": { "line": 28, "column": 33 }, "end": { "line": 28, "column": 54 } }, "object": { "type": "MemberExpression", "start": 904, "end": 918, "loc": { "start": { "line": 28, "column": 33 }, "end": { "line": 28, "column": 47 } }, "object": { "type": "ThisExpression", "start": 904, "end": 908, "loc": { "start": { "line": 28, "column": 33 }, "end": { "line": 28, "column": 37 } } }, "property": { "type": "Identifier", "start": 909, "end": 918, "loc": { "start": { "line": 28, "column": 38 }, "end": { "line": 28, "column": 47 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 919, "end": 925, "loc": { "start": { "line": 28, "column": 48 }, "end": { "line": 28, "column": 54 }, "identifierName": "config" }, "name": "config" }, "computed": false }, "property": { "type": "Identifier", "start": 926, "end": 930, "loc": { "start": { "line": 28, "column": 55 }, "end": { "line": 28, "column": 59 }, "identifierName": "port" }, "name": "port" }, "computed": false }, "operator": "||", "right": { "type": "NumericLiteral", "start": 934, "end": 938, "loc": { "start": { "line": 28, "column": 63 }, "end": { "line": 28, "column": 67 } }, "extra": { "rawValue": 3306, "raw": "3306" }, "value": 3306 } } } }, { "type": "TryStatement", "start": 944, "end": 1285, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 40, "column": 5 } }, "block": { "type": "BlockStatement", "start": 948, "end": 1128, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 35, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 956, "end": 1122, "loc": { "start": { "line": 30, "column": 6 }, "end": { "line": 34, "column": 7 } }, "test": { "type": "MemberExpression", "start": 960, "end": 994, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 44 } }, "object": { "type": "MemberExpression", "start": 960, "end": 976, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 26 } }, "object": { "type": "Identifier", "start": 960, "end": 969, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 19 }, "identifierName": "sequelize" }, "name": "sequelize" }, "property": { "type": "Identifier", "start": 970, "end": 976, "loc": { "start": { "line": 30, "column": 20 }, "end": { "line": 30, "column": 26 }, "identifierName": "config" }, "name": "config" }, "computed": false }, "property": { "type": "Identifier", "start": 977, "end": 994, "loc": { "start": { "line": 30, "column": 27 }, "end": { "line": 30, "column": 44 }, "identifierName": "dialectModulePath" }, "name": "dialectModulePath"