UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,572 lines (1,571 loc) 1.76 MB
{ "type": "File", "start": 0, "end": 12325, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 375, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 12325, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 375, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 79, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 64 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 78, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 63 } }, "id": { "type": "Identifier", "start": 21, "end": 30, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 15 }, "identifierName": "validator" }, "name": "validator" }, "init": { "type": "MemberExpression", "start": 33, "end": 78, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 63 } }, "object": { "type": "CallExpression", "start": 33, "end": 68, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 53 } }, "callee": { "type": "Identifier", "start": 33, "end": 40, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 41, "end": 67, "loc": { "start": { "line": 3, "column": 26 }, "end": { "line": 3, "column": 52 } }, "extra": { "rawValue": "./utils/validator-extras", "raw": "'./utils/validator-extras'" }, "value": "./utils/validator-extras" } ] }, "property": { "type": "Identifier", "start": 69, "end": 78, "loc": { "start": { "line": 3, "column": 54 }, "end": { "line": 3, "column": 63 }, "identifierName": "validator" }, "name": "validator" }, "computed": false } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 80, "end": 170, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 90 } }, "declarations": [ { "type": "VariableDeclarator", "start": 86, "end": 169, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 89 } }, "id": { "type": "Identifier", "start": 86, "end": 108, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 28 }, "identifierName": "extendModelValidations" }, "name": "extendModelValidations" }, "init": { "type": "MemberExpression", "start": 111, "end": 169, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 89 } }, "object": { "type": "CallExpression", "start": 111, "end": 146, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 66 } }, "callee": { "type": "Identifier", "start": 111, "end": 118, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 38 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 119, "end": 145, "loc": { "start": { "line": 4, "column": 39 }, "end": { "line": 4, "column": 65 } }, "extra": { "rawValue": "./utils/validator-extras", "raw": "'./utils/validator-extras'" }, "value": "./utils/validator-extras" } ] }, "property": { "type": "Identifier", "start": 147, "end": 169, "loc": { "start": { "line": 4, "column": 67 }, "end": { "line": 4, "column": 89 }, "identifierName": "extendModelValidations" }, "name": "extendModelValidations" }, "computed": false } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 171, "end": 204, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 177, "end": 203, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 32 } }, "id": { "type": "Identifier", "start": 177, "end": 182, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 11 }, "identifierName": "Utils" }, "name": "Utils" }, "init": { "type": "CallExpression", "start": 185, "end": 203, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 32 } }, "callee": { "type": "Identifier", "start": 185, "end": 192, "loc": { "start": { "line": 5, "column": 14 }, "end": { "line": 5, "column": 21 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 193, "end": 202, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 31 } }, "extra": { "rawValue": "./utils", "raw": "'./utils'" }, "value": "./utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 205, "end": 248, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 43 } }, "declarations": [ { "type": "VariableDeclarator", "start": 211, "end": 247, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 42 } }, "id": { "type": "Identifier", "start": 211, "end": 225, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 20 }, "identifierName": "sequelizeError" }, "name": "sequelizeError" }, "init": { "type": "CallExpression", "start": 228, "end": 247, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 42 } }, "callee": { "type": "Identifier", "start": 228, "end": 235, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 30 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 236, "end": 246, "loc": { "start": { "line": 6, "column": 31 }, "end": { "line": 6, "column": 41 } }, "extra": { "rawValue": "./errors", "raw": "'./errors'" }, "value": "./errors" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 249, "end": 286, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 255, "end": 285, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 36 } }, "id": { "type": "Identifier", "start": 255, "end": 262, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 13 }, "identifierName": "Promise" }, "name": "Promise" }, "init": { "type": "CallExpression", "start": 265, "end": 285, "loc": { "start": { "line": 7, "column": 16 }, "end": { "line": 7, "column": 36 } }, "callee": { "type": "Identifier", "start": 265, "end": 272, "loc": { "start": { "line": 7, "column": 16 }, "end": { "line": 7, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 273, "end": 284, "loc": { "start": { "line": 7, "column": 24 }, "end": { "line": 7, "column": 35 } }, "extra": { "rawValue": "./promise", "raw": "'./promise'" }, "value": "./promise" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 287, "end": 329, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 293, "end": 328, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 41 } }, "id": { "type": "Identifier", "start": 293, "end": 302, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 15 }, "identifierName": "DataTypes" }, "name": "DataTypes" }, "init": { "type": "CallExpression", "start": 305, "end": 328, "loc": { "start": { "line": 8, "column": 18 }, "end": { "line": 8, "column": 41 } }, "callee": { "type": "Identifier", "start": 305, "end": 312, "loc": { "start": { "line": 8, "column": 18 }, "end": { "line": 8, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 313, "end": 327, "loc": { "start": { "line": 8, "column": 26 }, "end": { "line": 8, "column": 40 } }, "extra": { "rawValue": "./data-types", "raw": "'./data-types'" }, "value": "./data-types" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 330, "end": 358, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 336, "end": 357, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 27 } }, "id": { "type": "Identifier", "start": 336, "end": 337, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 340, "end": 357, "loc": { "start": { "line": 9, "column": 10 }, "end": { "line": 9, "column": 27 } }, "callee": { "type": "Identifier", "start": 340, "end": 347, "loc": { "start": { "line": 9, "column": 10 }, "end": { "line": 9, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 348, "end": 356, "loc": { "start": { "line": 9, "column": 18 }, "end": { "line": 9, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\n * The Main Instance Validator.\n *\n * @param {Instance} modelInstance The model instance.\n * @param {Object} options A dict with options.\n * @constructor\n * @private\n ", "start": 360, "end": 533, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 18, "column": 3 } } } ] }, { "type": "ClassDeclaration", "start": 534, "end": 12048, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 365, "column": 1 } }, "id": { "type": "Identifier", "start": 540, "end": 557, "loc": { "start": { "line": 19, "column": 6 }, "end": { "line": 19, "column": 23 }, "identifierName": "InstanceValidator" }, "name": "InstanceValidator", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 558, "end": 12048, "loc": { "start": { "line": 19, "column": 24 }, "end": { "line": 365, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 563, "end": 1556, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 58, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 563, "end": 574, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 21, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 575, "end": 588, "loc": { "start": { "line": 21, "column": 14 }, "end": { "line": 21, "column": 27 }, "identifierName": "modelInstance" }, "name": "modelInstance" }, { "type": "Identifier", "start": 590, "end": 597, "loc": { "start": { "line": 21, "column": 29 }, "end": { "line": 21, "column": 36 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 599, "end": 1556, "loc": { "start": { "line": 21, "column": 38 }, "end": { "line": 58, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 605, "end": 638, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 37 } }, "expression": { "type": "AssignmentExpression", "start": 605, "end": 637, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 36 } }, "operator": "=", "left": { "type": "Identifier", "start": 605, "end": 612, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 11 }, "identifierName": "options" }, "name": "options" }, "right": { "type": "LogicalExpression", "start": 615, "end": 637, "loc": { "start": { "line": 22, "column": 14 }, "end": { "line": 22, "column": 36 } }, "left": { "type": "CallExpression", "start": 615, "end": 631, "loc": { "start": { "line": 22, "column": 14 }, "end": { "line": 22, "column": 30 } }, "callee": { "type": "MemberExpression", "start": 615, "end": 622, "loc": { "start": { "line": 22, "column": 14 }, "end": { "line": 22, "column": 21 } }, "object": { "type": "Identifier", "start": 615, "end": 616, "loc": { "start": { "line": 22, "column": 14 }, "end": { "line": 22, "column": 15 }, "identifierName": "_" }, "name": "_" }, "property": { "type": "Identifier", "start": 617, "end": 622, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 22, "column": 21 }, "identifierName": "clone" }, "name": "clone" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 623, "end": 630, "loc": { "start": { "line": 22, "column": 22 }, "end": { "line": 22, "column": 29 }, "identifierName": "options" }, "name": "options" } ] }, "operator": "||", "right": { "type": "ObjectExpression", "start": 635, "end": 637, "loc": { "start": { "line": 22, "column": 34 }, "end": { "line": 22, "column": 36 } }, "properties": [] } } } }, { "type": "IfStatement", "start": 644, "end": 796, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 26, "column": 5 } }, "test": { "type": "LogicalExpression", "start": 648, "end": 679, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 39 } }, "left": { "type": "MemberExpression", "start": 648, "end": 662, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 22 } }, "object": { "type": "Identifier", "start": 648, "end": 655, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 15 }, "identifierName": "options" }, "name": "options" }, "property": { "type": "Identifier", "start": 656, "end": 662, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 24, "column": 22 }, "identifierName": "fields" }, "name": "fields" }, "computed": false }, "operator": "&&", "right": { "type": "UnaryExpression", "start": 666, "end": 679, "loc": { "start": { "line": 24, "column": 26 }, "end": { "line": 24, "column": 39 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 667, "end": 679, "loc": { "start": { "line": 24, "column": 27 }, "end": { "line": 24, "column": 39 } }, "object": { "type": "Identifier", "start": 667, "end": 674, "loc": { "start": { "line": 24, "column": 27 }, "end": { "line": 24, "column": 34 }, "identifierName": "options" }, "name": "options" }, "property": { "type": "Identifier", "start": 675, "end": 679, "loc": { "start": { "line": 24, "column": 35 }, "end": { "line": 24, "column": 39 }, "identifierName": "skip" }, "name": "skip" }, "computed": false }, "extra": { "parenthesizedArgument": false } } }, "consequent": { "type": "BlockStatement", "start": 681, "end": 796, "loc": { "start": { "line": 24, "column": 41 }, "end": { "line": 26, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 689, "end": 790, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 107 } }, "expression": { "type": "AssignmentExpression", "start": 689, "end": 789, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 106 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 689, "end": 701, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 18 } }, "object": { "type": "Identifier", "start": 689, "end": 696, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 13 }, "identifierName": "options" }, "name": "options" }, "property": { "type": "Identifier", "start": 697, "end": 701, "loc": { "start": { "line": 25, "column": 14 }, "end": { "line": 25, "column": 18 }, "identifierName": "skip" }, "name": "skip" }, "computed": false }, "right": { "type": "CallExpression", "start": 704, "end": 789, "loc": { "start": { "line": 25, "column": 21 }, "end": { "line": 25, "column": 106 } }, "callee": { "type": "MemberExpression", "start": 704, "end": 722, "loc": { "start": { "line": 25, "column": 21 }, "end": { "line": 25, "column": 39 } }, "object": { "type": "MemberExpression", "start": 704, "end": 711, "loc": { "start": { "line": 25, "column": 21 }, "end": { "line": 25, "column": 28 } }, "object": { "type": "Identifier", "start": 704, "end": 709, "loc": { "start": { "line": 25, "column": 21 }, "end": { "line": 25, "column": 26 }, "identifierName": "Utils" }, "name": "Utils" }, "property": { "type": "Identifier", "start": 710, "end": 711, "loc": { "start": { "line": 25, "column": 27 }, "end": { "line": 25, "column": 28 }, "identifierName": "_" }, "name": "_" }, "computed": false }, "property": { "type": "Identifier", "start": 712, "end": 722, "loc": { "start": { "line": 25, "column": 29 }, "end": { "line": 25, "column": 39 }, "identifierName": "difference" }, "name": "difference" }, "computed": false }, "arguments": [ { "type": "CallExpression", "start": 723, "end": 772, "loc": { "start": { "line": 25, "column": 40 }, "end": { "line": 25, "column": 89 } }, "callee": { "type": "MemberExpression", "start": 723, "end": 734, "loc": { "start": { "line": 25, "column": 40 }, "end": { "line": 25, "column": 51 } }, "object": { "type": "Identifier", "start": 723, "end": 729, "loc": { "start": { "line": 25, "column": 40 }, "end": { "line": 25, "column": 46 }, "identifierName": "Object" }, "name": "Object" }, "property": { "type": "Identifier", "start": 730, "end": 734, "loc": { "start": { "line": 25, "column": 47 }, "end": { "line": 25, "column": 51 }, "identifierName": "keys" }, "name": "keys" }, "computed": false }, "arguments": [ { "type": "MemberExpression", "start": 735, "end": 771, "loc": { "start": { "line": 25, "column": 52 }, "end": { "line": 25, "column": 88 } }, "object": { "type": "MemberExpression", "start": 735, "end": 760, "loc": { "start": { "line": 25,