UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,473 lines (1,472 loc) 481 kB
{ "type": "File", "start": 0, "end": 2223, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 99, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2223, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 99, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 58, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 43 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 57, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 42 } }, "id": { "type": "Identifier", "start": 21, "end": 29, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 14 }, "identifierName": "Toposort" }, "name": "Toposort" }, "init": { "type": "CallExpression", "start": 32, "end": 57, "loc": { "start": { "line": 3, "column": 17 }, "end": { "line": 3, "column": 42 } }, "callee": { "type": "Identifier", "start": 32, "end": 39, "loc": { "start": { "line": 3, "column": 17 }, "end": { "line": 3, "column": 24 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 40, "end": 56, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 3, "column": 41 } }, "extra": { "rawValue": "toposort-class", "raw": "'toposort-class'" }, "value": "toposort-class" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 59, "end": 87, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 65, "end": 86, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 27 } }, "id": { "type": "Identifier", "start": 65, "end": 66, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 69, "end": 86, "loc": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 27 } }, "callee": { "type": "Identifier", "start": 69, "end": 76, "loc": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 77, "end": 85, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const" }, { "type": "ClassDeclaration", "start": 89, "end": 2107, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 94, "column": 1 } }, "id": { "type": "Identifier", "start": 95, "end": 107, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 18 }, "identifierName": "ModelManager" }, "name": "ModelManager" }, "superClass": null, "body": { "type": "ClassBody", "start": 108, "end": 2107, "loc": { "start": { "line": 6, "column": 19 }, "end": { "line": 94, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 112, "end": 194, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 10, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 112, "end": 123, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 124, "end": 133, "loc": { "start": { "line": 7, "column": 14 }, "end": { "line": 7, "column": 23 }, "identifierName": "sequelize" }, "name": "sequelize" } ], "body": { "type": "BlockStatement", "start": 135, "end": 194, "loc": { "start": { "line": 7, "column": 25 }, "end": { "line": 10, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 141, "end": 158, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 21 } }, "expression": { "type": "AssignmentExpression", "start": 141, "end": 157, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 20 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 141, "end": 152, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 15 } }, "object": { "type": "ThisExpression", "start": 141, "end": 145, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 8 } } }, "property": { "type": "Identifier", "start": 146, "end": 152, "loc": { "start": { "line": 8, "column": 9 }, "end": { "line": 8, "column": 15 }, "identifierName": "models" }, "name": "models" }, "computed": false }, "right": { "type": "ArrayExpression", "start": 155, "end": 157, "loc": { "start": { "line": 8, "column": 18 }, "end": { "line": 8, "column": 20 } }, "elements": [] } } }, { "type": "ExpressionStatement", "start": 163, "end": 190, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 163, "end": 189, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 163, "end": 177, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 18 } }, "object": { "type": "ThisExpression", "start": 163, "end": 167, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 8 } } }, "property": { "type": "Identifier", "start": 168, "end": 177, "loc": { "start": { "line": 9, "column": 9 }, "end": { "line": 9, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "right": { "type": "Identifier", "start": 180, "end": 189, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 30 }, "identifierName": "sequelize" }, "name": "sequelize" } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 198, "end": 314, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 17, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 198, "end": 206, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 10 }, "identifierName": "addModel" }, "name": "addModel" }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 207, "end": 212, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 16 }, "identifierName": "model" }, "name": "model" } ], "body": { "type": "BlockStatement", "start": 214, "end": 314, "loc": { "start": { "line": 12, "column": 18 }, "end": { "line": 17, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 220, "end": 244, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 28 } }, "expression": { "type": "CallExpression", "start": 220, "end": 243, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 27 } }, "callee": { "type": "MemberExpression", "start": 220, "end": 236, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 20 } }, "object": { "type": "MemberExpression", "start": 220, "end": 231, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 15 } }, "object": { "type": "ThisExpression", "start": 220, "end": 224, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 8 } } }, "property": { "type": "Identifier", "start": 225, "end": 231, "loc": { "start": { "line": 13, "column": 9 }, "end": { "line": 13, "column": 15 }, "identifierName": "models" }, "name": "models" }, "computed": false }, "property": { "type": "Identifier", "start": 232, "end": 236, "loc": { "start": { "line": 13, "column": 16 }, "end": { "line": 13, "column": 20 }, "identifierName": "push" }, "name": "push" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 237, "end": 242, "loc": { "start": { "line": 13, "column": 21 }, "end": { "line": 13, "column": 26 }, "identifierName": "model" }, "name": "model" } ] } }, { "type": "ExpressionStatement", "start": 249, "end": 291, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 46 } }, "expression": { "type": "AssignmentExpression", "start": 249, "end": 290, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 45 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 249, "end": 282, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 37 } }, "object": { "type": "MemberExpression", "start": 249, "end": 270, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 25 } }, "object": { "type": "MemberExpression", "start": 249, "end": 263, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 18 } }, "object": { "type": "ThisExpression", "start": 249, "end": 253, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 8 } } }, "property": { "type": "Identifier", "start": 254, "end": 263, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 264, "end": 270, "loc": { "start": { "line": 14, "column": 19 }, "end": { "line": 14, "column": 25 }, "identifierName": "models" }, "name": "models" }, "computed": false }, "property": { "type": "MemberExpression", "start": 271, "end": 281, "loc": { "start": { "line": 14, "column": 26 }, "end": { "line": 14, "column": 36 } }, "object": { "type": "Identifier", "start": 271, "end": 276, "loc": { "start": { "line": 14, "column": 26 }, "end": { "line": 14, "column": 31 }, "identifierName": "model" }, "name": "model" }, "property": { "type": "Identifier", "start": 277, "end": 281, "loc": { "start": { "line": 14, "column": 32 }, "end": { "line": 14, "column": 36 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "computed": true }, "right": { "type": "Identifier", "start": 285, "end": 290, "loc": { "start": { "line": 14, "column": 40 }, "end": { "line": 14, "column": 45 }, "identifierName": "model" }, "name": "model" } } }, { "type": "ReturnStatement", "start": 297, "end": 310, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 17 } }, "argument": { "type": "Identifier", "start": 304, "end": 309, "loc": { "start": { "line": 16, "column": 11 }, "end": { "line": 16, "column": 16 }, "identifierName": "model" }, "name": "model" } } ], "directives": [] } }, { "type": "ClassMethod", "start": 318, "end": 487, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 23, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 318, "end": 329, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 13 }, "identifierName": "removeModel" }, "name": "removeModel" }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 330, "end": 343, "loc": { "start": { "line": 19, "column": 14 }, "end": { "line": 19, "column": 27 }, "identifierName": "modelToRemove" }, "name": "modelToRemove" } ], "body": { "type": "BlockStatement", "start": 345, "end": 487, "loc": { "start": { "line": 19, "column": 29 }, "end": { "line": 23, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 351, "end": 428, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 81 } }, "expression": { "type": "AssignmentExpression", "start": 351, "end": 427, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 80 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 351, "end": 362, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 15 } }, "object": { "type": "ThisExpression", "start": 351, "end": 355, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 8 } } }, "property": { "type": "Identifier", "start": 356, "end": 362, "loc": { "start": { "line": 20, "column": 9 }, "end": { "line": 20, "column": 15 }, "identifierName": "models" }, "name": "models" }, "computed": false }, "right": { "type": "CallExpression", "start": 365, "end": 427, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 80 } }, "callee": { "type": "MemberExpression", "start": 365, "end": 383, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 36 } }, "object": { "type": "MemberExpression", "start": 365, "end": 376, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 29 } }, "object": { "type": "ThisExpression", "start": 365, "end": 369, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 20, "column": 22 } } }, "property": { "type": "Identifier", "start": 370, "end": 376, "loc": { "start": { "line": 20, "column": 23 }, "end": { "line": 20, "column": 29 }, "identifierName": "models" }, "name": "models" }, "computed": false }, "property": { "type": "Identifier", "start": 377, "end": 383, "loc": { "start": { "line": 20, "column": 30 }, "end": { "line": 20, "column": 36 }, "identifierName": "filter" }, "name": "filter" }, "computed": false }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 384, "end": 426, "loc": { "start": { "line": 20, "column": 37 }, "end": { "line": 20, "column": 79 } }, "id": null, "generator": false, "expression": true, "async": false, "params": [ { "type": "Identifier", "start": 384, "end": 389, "loc": { "start": { "line": 20, "column": 37 }, "end": { "line": 20, "column": 42 }, "identifierName": "model" }, "name": "model" } ], "body": { "type": "BinaryExpression", "start": 393, "end": 426, "loc": { "start": { "line": 20, "column": 46 }, "end": { "line": 20, "column": 79 } }, "left": { "type": "MemberExpression", "start": 393, "end": 403, "loc": { "start": { "line": 20, "column": 46 }, "end": { "line": 20, "column": 56 } }, "object": { "type": "Identifier", "start": 393, "end": 398, "loc": { "start": { "line": 20, "column": 46 }, "end": { "line": 20, "column": 51 }, "identifierName": "model" }, "name": "model" }, "property": { "type": "Identifier", "start": 399, "end": 403, "loc": { "start": { "line": 20, "column": 52 }, "end": { "line": 20, "column": 56 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "operator": "!==", "right": { "type": "MemberExpression", "start": 408, "end": 426, "loc": { "start": { "line": 20, "column": 61 }, "end": { "line": 20, "column": 79 } }, "object": { "type": "Identifier", "start": 408, "end": 421, "loc": { "start": { "line": 20, "column": 61 }, "end": { "line": 20, "column": 74 }, "identifierName": "modelToRemove" }, "name": "modelToRemove" }, "property": { "type": "Identifier", "start": 422, "end": 426, "loc": { "start": { "line": 20, "column": 75 }, "end": { "line": 20, "column": 79 }, "identifierName": "name" }, "name": "name" }, "computed": false } } } ] } } }, { "type": "ExpressionStatement", "start": 434, "end": 483, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 53 } }, "expression": { "type": "UnaryExpression", "start": 434, "end": 482, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 52 } }, "operator": "delete", "prefix": true, "argument": { "type": "MemberExpression", "start": 441, "end": 482, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 52 } }, "object": { "type": "MemberExpression", "start": 441, "end": 462, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 32 } }, "object": { "type": "MemberExpression", "start": 441, "end": 455, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 25 } }, "object": { "type": "ThisExpression", "start": 441, "end": 445, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 15