UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,554 lines 2.68 MB
{ "type": "File", "start": 0, "end": 15060, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 465, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 15060, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 465, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 51, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 36 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 50, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 35 } }, "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": 50, "loc": { "start": { "line": 3, "column": 14 }, "end": { "line": 3, "column": 35 } }, "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": 49, "loc": { "start": { "line": 3, "column": 22 }, "end": { "line": 3, "column": 34 } }, "extra": { "rawValue": "./../utils", "raw": "'./../utils'" }, "value": "./../utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 52, "end": 89, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 58, "end": 88, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 36 } }, "id": { "type": "Identifier", "start": 58, "end": 65, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 13 }, "identifierName": "Helpers" }, "name": "Helpers" }, "init": { "type": "CallExpression", "start": 68, "end": 88, "loc": { "start": { "line": 4, "column": 16 }, "end": { "line": 4, "column": 36 } }, "callee": { "type": "Identifier", "start": 68, "end": 75, "loc": { "start": { "line": 4, "column": 16 }, "end": { "line": 4, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 76, "end": 87, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 35 } }, "extra": { "rawValue": "./helpers", "raw": "'./helpers'" }, "value": "./helpers" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 90, "end": 118, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 96, "end": 117, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 27 } }, "id": { "type": "Identifier", "start": 96, "end": 97, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 100, "end": 117, "loc": { "start": { "line": 5, "column": 10 }, "end": { "line": 5, "column": 27 } }, "callee": { "type": "Identifier", "start": 100, "end": 107, "loc": { "start": { "line": 5, "column": 10 }, "end": { "line": 5, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 108, "end": 116, "loc": { "start": { "line": 5, "column": 18 }, "end": { "line": 5, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 119, "end": 157, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 38 } }, "declarations": [ { "type": "VariableDeclarator", "start": 125, "end": 156, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 37 } }, "id": { "type": "Identifier", "start": 125, "end": 136, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 17 }, "identifierName": "Association" }, "name": "Association" }, "init": { "type": "CallExpression", "start": 139, "end": 156, "loc": { "start": { "line": 6, "column": 20 }, "end": { "line": 6, "column": 37 } }, "callee": { "type": "Identifier", "start": 139, "end": 146, "loc": { "start": { "line": 6, "column": 20 }, "end": { "line": 6, "column": 27 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 147, "end": 155, "loc": { "start": { "line": 6, "column": 28 }, "end": { "line": 6, "column": 36 } }, "extra": { "rawValue": "./base", "raw": "'./base'" }, "value": "./base" } ] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\n * One-to-many association\n *\n * In the API reference below, add the name of the association to the method, e.g. for `User.hasMany(Project)` the getter will be `user.getProjects()`.\n * If the association is aliased, use the alias instead, e.g. `User.hasMany(Project, { as: 'jobs' })` will be `user.getJobs()`.\n *\n * @see {@link Model.hasMany}\n ", "start": 159, "end": 509, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 15, "column": 3 } } } ] }, { "type": "ClassDeclaration", "start": 510, "end": 14964, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 460, "column": 1 } }, "id": { "type": "Identifier", "start": 516, "end": 523, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 16, "column": 13 }, "identifierName": "HasMany" }, "name": "HasMany", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 532, "end": 543, "loc": { "start": { "line": 16, "column": 22 }, "end": { "line": 16, "column": 33 }, "identifierName": "Association" }, "name": "Association" }, "body": { "type": "ClassBody", "start": 544, "end": 14964, "loc": { "start": { "line": 16, "column": 34 }, "end": { "line": 460, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 548, "end": 3656, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 111, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 548, "end": 559, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 560, "end": 566, "loc": { "start": { "line": 17, "column": 14 }, "end": { "line": 17, "column": 20 }, "identifierName": "source" }, "name": "source" }, { "type": "Identifier", "start": 568, "end": 574, "loc": { "start": { "line": 17, "column": 22 }, "end": { "line": 17, "column": 28 }, "identifierName": "target" }, "name": "target" }, { "type": "Identifier", "start": 576, "end": 583, "loc": { "start": { "line": 17, "column": 30 }, "end": { "line": 17, "column": 37 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 585, "end": 3656, "loc": { "start": { "line": 17, "column": 39 }, "end": { "line": 111, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 591, "end": 622, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 35 } }, "expression": { "type": "CallExpression", "start": 591, "end": 621, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 34 } }, "callee": { "type": "Super", "start": 591, "end": 596, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 9 } } }, "arguments": [ { "type": "Identifier", "start": 597, "end": 603, "loc": { "start": { "line": 18, "column": 10 }, "end": { "line": 18, "column": 16 }, "identifierName": "source" }, "name": "source" }, { "type": "Identifier", "start": 605, "end": 611, "loc": { "start": { "line": 18, "column": 18 }, "end": { "line": 18, "column": 24 }, "identifierName": "target" }, "name": "target" }, { "type": "Identifier", "start": 613, "end": 620, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 33 }, "identifierName": "options" }, "name": "options" } ] } }, { "type": "ExpressionStatement", "start": 628, "end": 661, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 37 } }, "expression": { "type": "AssignmentExpression", "start": 628, "end": 660, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 36 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 628, "end": 648, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 24 } }, "object": { "type": "ThisExpression", "start": 628, "end": 632, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 8 } } }, "property": { "type": "Identifier", "start": 633, "end": 648, "loc": { "start": { "line": 20, "column": 9 }, "end": { "line": 20, "column": 24 }, "identifierName": "associationType" }, "name": "associationType" }, "computed": false }, "right": { "type": "StringLiteral", "start": 651, "end": 660, "loc": { "start": { "line": 20, "column": 27 }, "end": { "line": 20, "column": 36 } }, "extra": { "rawValue": "HasMany", "raw": "'HasMany'" }, "value": "HasMany" } } }, { "type": "ExpressionStatement", "start": 666, "end": 696, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 666, "end": 695, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 666, "end": 688, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 26 } }, "object": { "type": "ThisExpression", "start": 666, "end": 670, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 8 } } }, "property": { "type": "Identifier", "start": 671, "end": 688, "loc": { "start": { "line": 21, "column": 9 }, "end": { "line": 21, "column": 26 }, "identifierName": "targetAssociation" }, "name": "targetAssociation" }, "computed": false }, "right": { "type": "NullLiteral", "start": 691, "end": 695, "loc": { "start": { "line": 21, "column": 29 }, "end": { "line": 21, "column": 33 } } } } }, { "type": "ExpressionStatement", "start": 701, "end": 735, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 38 } }, "expression": { "type": "AssignmentExpression", "start": 701, "end": 734, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 37 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 701, "end": 715, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 18 } }, "object": { "type": "ThisExpression", "start": 701, "end": 705, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 8 } } }, "property": { "type": "Identifier", "start": 706, "end": 715, "loc": { "start": { "line": 22, "column": 9 }, "end": { "line": 22, "column": 18 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "right": { "type": "MemberExpression", "start": 718, "end": 734, "loc": { "start": { "line": 22, "column": 21 }, "end": { "line": 22, "column": 37 } }, "object": { "type": "Identifier", "start": 718, "end": 724, "loc": { "start": { "line": 22, "column": 21 }, "end": { "line": 22, "column": 27 }, "identifierName": "source" }, "name": "source" }, "property": { "type": "Identifier", "start": 725, "end": 734, "loc": { "start": { "line": 22, "column": 28 }, "end": { "line": 22, "column": 37 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false } } }, { "type": "ExpressionStatement", "start": 740, "end": 771, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 35 } }, "expression": { "type": "AssignmentExpression", "start": 740, "end": 770, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 740, "end": 752, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 16 } }, "object": { "type": "ThisExpression", "start": 740, "end": 744, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 8 } } }, "property": { "type": "Identifier", "start": 745, "end": 752, "loc": { "start": { "line": 23, "column": 9 }, "end": { "line": 23, "column": 16 }, "identifierName": "through" }, "name": "through" }, "computed": false }, "right": { "type": "MemberExpression", "start": 755, "end": 770, "loc": { "start": { "line": 23, "column": 19 }, "end": { "line": 23, "column": 34 } }, "object": { "type": "Identifier", "start": 755, "end": 762, "loc": { "start": { "line": 23, "column": 19 }, "end": { "line": 23, "column": 26 }, "identifierName": "options" }, "name": "options" }, "property": { "type": "Identifier", "start": 763, "end": 770, "loc": { "start": { "line": 23, "column": 27 }, "end": { "line": 23, "column": 34 }, "identifierName": "through" }, "name": "through" }, "computed": false } } }, { "type": "ExpressionStatement", "start": 776, "end": 807, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 35 } }, "expression": { "type": "AssignmentExpression", "start": 776, "end": 806, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 776, "end": 799, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 27 } }, "object": { "type": "ThisExpression", "start": 776, "end": 780, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 8 } } }, "property": { "type": "Identifier", "start": 781, "end": 799, "loc": { "start": { "line": 24, "column": 9 }, "end": { "line": 24, "column": 27 }, "identifierName": "isMultiAssociation" }, "name": "isMultiAssociation" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 802, "end": 806, "loc": { "start": { "line": 24, "column": 30 }, "end": { "line": 24, "column": 34 } }, "value": true } } }, { "type": "ExpressionStatement", "start": 812, "end": 842, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 812, "end": 841, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 812, "end": 836, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 28 } }, "object": { "type": "ThisExpression", "start": 812, "end": 816, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 8 } } }, "property": { "type": "Identifier", "start": 817, "end": 836, "loc": { "start": { "line": 25, "column": 9 }, "end": { "line": 25, "column": 28 }, "identifierName": "foreignKeyAttribute" }, "name": "foreignKeyAttribute" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 839, "end": 841, "loc": { "start": { "line": 25, "column": 31 }, "end": { "line": 25, "column": 33 } }, "properties": [] } } }, { "type": "IfStatement", "start": 848, "end": 982, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 29, "column": 5 } }, "test": { "type": "MemberExpression", "start": 852, "end": 872, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 28 } }, "object": { "type": "MemberExpression", "start": 852, "end": 864, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 20 } }, "object": { "type": "ThisExpression", "start": 852, "end": 856, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 12 } } }, "property": { "type": "Identifier", "start": 857, "end": 864, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 20 }, "identifierName": "options" }, "name": "options" }, "computed": false }, "property": { "type": "Identifier", "start": 865, "end": 872, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 27, "column": 28 }, "identifierName": "through" }, "name": "through" }, "computed": false }, "consequent": { "type": "BlockStatement", "start": 874, "end": 982, "loc": { "start": { "line": 27, "column": 30 }, "end": { "line": 29, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 882, "end": 976, "loc": { "start": { "line": 28, "column": 6 }, "end": { "line": 28, "column": 100 } }, "argument": { "type": "NewExpression", "start": 888, "end": 975, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 99 } }, "callee": { "type": "Identifier", "start": 892, "end": 897, "loc": { "start": { "line": 28, "column": 16 }, "end": { "line": 28, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 898, "end": 974, "loc": { "start": { "line": 28, "column": 22 }, "end": { "line": 28, "column": 98 } }, "extra": { "rawValue": "N:M associations are not supported with hasMany. Use belongsToMany instead", "raw": "'N:M associations are not supported with hasMany. Use belongsToMany instead'" }, "value": "N:M associations are not supported with hasMany. Use belongsToMany instead" } ] } } ], "directive