UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,891 lines (1,890 loc) 24.6 MB
{ "type": "File", "start": 0, "end": 174222, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 4026, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 174222, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 4026, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 48, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 47, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 32 } }, "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": 47, "loc": { "start": { "line": 3, "column": 14 }, "end": { "line": 3, "column": 32 } }, "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": 46, "loc": { "start": { "line": 3, "column": 22 }, "end": { "line": 3, "column": 31 } }, "extra": { "rawValue": "./utils", "raw": "'./utils'" }, "value": "./utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 49, "end": 104, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 55 } }, "declarations": [ { "type": "VariableDeclarator", "start": 55, "end": 103, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 54 } }, "id": { "type": "Identifier", "start": 55, "end": 64, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 15 }, "identifierName": "BelongsTo" }, "name": "BelongsTo" }, "init": { "type": "CallExpression", "start": 67, "end": 103, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 54 } }, "callee": { "type": "Identifier", "start": 67, "end": 74, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 75, "end": 102, "loc": { "start": { "line": 4, "column": 26 }, "end": { "line": 4, "column": 53 } }, "extra": { "rawValue": "./associations/belongs-to", "raw": "'./associations/belongs-to'" }, "value": "./associations/belongs-to" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 105, "end": 169, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 64 } }, "declarations": [ { "type": "VariableDeclarator", "start": 111, "end": 168, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 63 } }, "id": { "type": "Identifier", "start": 111, "end": 124, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 19 }, "identifierName": "BelongsToMany" }, "name": "BelongsToMany" }, "init": { "type": "CallExpression", "start": 127, "end": 168, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 63 } }, "callee": { "type": "Identifier", "start": 127, "end": 134, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 29 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 135, "end": 167, "loc": { "start": { "line": 5, "column": 30 }, "end": { "line": 5, "column": 62 } }, "extra": { "rawValue": "./associations/belongs-to-many", "raw": "'./associations/belongs-to-many'" }, "value": "./associations/belongs-to-many" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 170, "end": 228, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 58 } }, "declarations": [ { "type": "VariableDeclarator", "start": 176, "end": 227, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 57 } }, "id": { "type": "Identifier", "start": 176, "end": 193, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 23 }, "identifierName": "InstanceValidator" }, "name": "InstanceValidator" }, "init": { "type": "CallExpression", "start": 196, "end": 227, "loc": { "start": { "line": 6, "column": 26 }, "end": { "line": 6, "column": 57 } }, "callee": { "type": "Identifier", "start": 196, "end": 203, "loc": { "start": { "line": 6, "column": 26 }, "end": { "line": 6, "column": 33 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 204, "end": 226, "loc": { "start": { "line": 6, "column": 34 }, "end": { "line": 6, "column": 56 } }, "extra": { "rawValue": "./instance-validator", "raw": "'./instance-validator'" }, "value": "./instance-validator" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 229, "end": 273, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 44 } }, "declarations": [ { "type": "VariableDeclarator", "start": 235, "end": 272, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 43 } }, "id": { "type": "Identifier", "start": 235, "end": 245, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 16 }, "identifierName": "QueryTypes" }, "name": "QueryTypes" }, "init": { "type": "CallExpression", "start": 248, "end": 272, "loc": { "start": { "line": 7, "column": 19 }, "end": { "line": 7, "column": 43 } }, "callee": { "type": "Identifier", "start": 248, "end": 255, "loc": { "start": { "line": 7, "column": 19 }, "end": { "line": 7, "column": 26 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 256, "end": 271, "loc": { "start": { "line": 7, "column": 27 }, "end": { "line": 7, "column": 42 } }, "extra": { "rawValue": "./query-types", "raw": "'./query-types'" }, "value": "./query-types" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 274, "end": 318, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 44 } }, "declarations": [ { "type": "VariableDeclarator", "start": 280, "end": 317, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 43 } }, "id": { "type": "Identifier", "start": 280, "end": 295, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 21 }, "identifierName": "sequelizeErrors" }, "name": "sequelizeErrors" }, "init": { "type": "CallExpression", "start": 298, "end": 317, "loc": { "start": { "line": 8, "column": 24 }, "end": { "line": 8, "column": 43 } }, "callee": { "type": "Identifier", "start": 298, "end": 305, "loc": { "start": { "line": 8, "column": 24 }, "end": { "line": 8, "column": 31 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 306, "end": 316, "loc": { "start": { "line": 8, "column": 32 }, "end": { "line": 8, "column": 42 } }, "extra": { "rawValue": "./errors", "raw": "'./errors'" }, "value": "./errors" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 319, "end": 352, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 325, "end": 351, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 32 } }, "id": { "type": "Identifier", "start": 325, "end": 331, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 12 }, "identifierName": "Dottie" }, "name": "Dottie" }, "init": { "type": "CallExpression", "start": 334, "end": 351, "loc": { "start": { "line": 9, "column": 15 }, "end": { "line": 9, "column": 32 } }, "callee": { "type": "Identifier", "start": 334, "end": 341, "loc": { "start": { "line": 9, "column": 15 }, "end": { "line": 9, "column": 22 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 342, "end": 350, "loc": { "start": { "line": 9, "column": 23 }, "end": { "line": 9, "column": 31 } }, "extra": { "rawValue": "dottie", "raw": "'dottie'" }, "value": "dottie" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 353, "end": 390, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 359, "end": 389, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 36 } }, "id": { "type": "Identifier", "start": 359, "end": 366, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 13 }, "identifierName": "Promise" }, "name": "Promise" }, "init": { "type": "CallExpression", "start": 369, "end": 389, "loc": { "start": { "line": 10, "column": 16 }, "end": { "line": 10, "column": 36 } }, "callee": { "type": "Identifier", "start": 369, "end": 376, "loc": { "start": { "line": 10, "column": 16 }, "end": { "line": 10, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 377, "end": 388, "loc": { "start": { "line": 10, "column": 24 }, "end": { "line": 10, "column": 35 } }, "extra": { "rawValue": "./promise", "raw": "'./promise'" }, "value": "./promise" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 391, "end": 419, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 397, "end": 418, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 27 } }, "id": { "type": "Identifier", "start": 397, "end": 398, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 401, "end": 418, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 27 } }, "callee": { "type": "Identifier", "start": 401, "end": 408, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 409, "end": 417, "loc": { "start": { "line": 11, "column": 18 }, "end": { "line": 11, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 420, "end": 453, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 426, "end": 452, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 32 } }, "id": { "type": "Identifier", "start": 426, "end": 432, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 12 }, "identifierName": "moment" }, "name": "moment" }, "init": { "type": "CallExpression", "start": 435, "end": 452, "loc": { "start": { "line": 12, "column": 15 }, "end": { "line": 12, "column": 32 } }, "callee": { "type": "Identifier", "start": 435, "end": 442, "loc": { "start": { "line": 12, "column": 15 }, "end": { "line": 12, "column": 22 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 443, "end": 451, "loc": { "start": { "line": 12, "column": 23 }, "end": { "line": 12, "column": 31 } }, "extra": { "rawValue": "moment", "raw": "'moment'" }, "value": "moment" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 454, "end": 505, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 51 } }, "declarations": [ { "type": "VariableDeclarator", "start": 460, "end": 504, "loc": { "start": { "line": 13, "column": 6 }, "end": { "line": 13, "column": 50 } }, "id": { "type": "Identifier", "start": 460, "end": 471, "loc": { "start": { "line": 13, "column": 6 }, "end": { "line": 13, "column": 17 }, "identifierName": "Association" }, "name": "Association" }, "init": { "type": "CallExpression", "start": 474, "end": 504, "loc": { "start": { "line": 13, "column": 20 }, "end": { "line": 13, "column": 50 } }, "callee": { "type": "Identifier", "start": 474, "end": 481, "loc": { "start": { "line": 13, "column": 20 }, "end": { "line": 13, "column": 27 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 482, "end": 503, "loc": { "start": { "line": 13, "column": 28 }, "end": { "line": 13, "column": 49 } }, "extra": { "rawValue": "./associations/base", "raw": "'./associations/base'" }, "value": "./associations/base" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 506, "end": 557, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 14, "column": 51 } }, "declarations": [ { "type": "VariableDeclarator", "start": 512, "end": 556, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 50 } }, "id": { "type": "Identifier", "start": 512, "end": 519, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 13 }, "identifierName": "HasMany" }, "name": "HasMany" }, "init": { "type": "CallExpression", "start": 522, "end": 556, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 50 } }, "callee": { "type": "Identifier", "start": 522, "end": 529, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 530, "end": 555, "loc": { "start": { "line": 14, "column": 24 }, "end": { "line": 14, "column": 49 } }, "extra": { "rawValue": "./associations/has-many", "raw": "'./associations/has-many'" }, "value": "./associations/has-many" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 558, "end": 600, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 564, "end": 599, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 41 } }, "id": { "type": "Identifier", "start": 564, "end": 573, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 15 }, "identifierName": "DataTypes" }, "name": "DataTypes" }, "init": { "type": "CallExpression", "start": 576, "end": 599, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 15, "column": 41 } }, "callee": { "type": "Identifier", "start": 576, "end": 583, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 15, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 584, "end": 598, "loc": { "start": { "line": 15, "column": 26 }, "end": { "line": 15, "column": 40 } }, "extra": { "rawValue": "./data-types", "raw": "'./data-types'" }, "value": "./data-types" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 601, "end": 634, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 607, "end": 633, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 16, "column": 32 } }, "id": { "type": "Identifier", "start": 607, "end": 612, "loc": { "start": { "line": 16, "column": 6 }, "end": { "line": 16, "column": 11 }, "identifierName": "Hooks" }, "name": "Hooks" }, "init": { "type": "CallExpression", "start": 615, "end": 633, "loc": { "start": { "line": 16, "column": 14 }, "end": { "line": 16, "column": 32 } }, "callee": { "type": "Identifier", "start": 615, "end": 622, "loc": { "start": { "line": 16, "column": 14 }, "end": { "line": 16, "column": 21 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 623, "end": 632, "loc": { "start": { "line": 16, "column": 22 }, "end": { "line": 16, "column": 31 } }, "extra": { "rawValue": "./hooks", "raw": "'./hooks'" }, "value": "./hooks" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 635, "end": 693, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 58 } }, "declarations": [ { "type": "VariableDeclarator", "start": 641, "end": 692, "loc": { "start": { "line": 17, "column": 6 }, "end": { "line": 17, "column": 57 } }, "id": { "type": "Identifier", "start": 641, "end": 658, "loc": { "start": { "line": 17, "column": 6 }, "end": { "line": 17, "column": 23 }, "identifierName": "associationsMixin" }, "name": "associationsMixin" }, "init": { "type": "CallExpression", "start": 661, "end": 692, "loc": { "start": { "line": 17, "column": 26 }, "end": { "line": 17, "column": 57 } }, "callee": { "type": "Identifier", "start": 661, "end": 668, "loc": { "start": { "line": 17, "column": 26 }, "end": { "line": 17, "column": 33 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 669, "end": 691, "loc": { "start": { "line": 17, "column": 34 }, "end": { "line": 17, "column": 56 } }, "extra": { "rawValue": "./associations/mixin", "raw": "'./associations/mixin'" }, "value": "./associations/mixin" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 694, "end": 732, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 18, "column": 38 } }, "declarations": [ { "type": "VariableDeclarator", "start": 700, "end": 731, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 37 } }, "id": { "type": "Identifier", "start": 700, "end": 715, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 21 }, "identifierName": "defaultsOptions" }, "name": "defaultsOptions" }, "init": { "type": "ObjectExpression", "start": 718, "end": 731, "loc": { "start": { "line": 18, "column": 24 }, "end": { "line": 18, "column": 37 } }, "properties": [ { "type": "ObjectProperty", "start": 720, "end": 729, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 720, "end": 723, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 29 }, "identifierName": "raw" }, "name": "raw" }, "value": { "type": "BooleanLiteral", "start": 725, "end": 729, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 35 } }, "value": true } } ] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\n * A Model represents a table in the database. Instances of this class represent a database row.\n *\n * Model instances operate with the concept of a `dataValues` property, which stores the actual values represented by the instance.\n * By default, the values from dataValues can also be accessed directly from the Instance, that is:\n * ```js\n * instance.field\n * // is the same as\n * instance.get('field')\n * // is the same as\n * instance.getDataValue('field')\n * ```\n * However, if getters and/or setters are defined for `field` they will be invoked, instead of returning the value from `dataValues`.\n * Accessing properties directly or using `get` is preferred for regular use, `getDataValue` should only be used for custom getters.\n *\n * @see {@link Sequelize#define} for more information about getters and setters\n * @class Model\n * @mixes Hooks\n ", "start": 734, "end": 1590, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 38, "column": 3 } } } ] }, { "type": "ClassDeclaration", "start": 1591, "end": 173703, "loc": { "start": { "line": 39, "column": 0 }, "end": { "line": 4008, "column": 1 } }, "id": { "type": "Identifier", "start": 1597, "end": 1602, "loc": { "start": { "line": 39, "column": 6 }, "end": { "line": 39, "column": 11 }, "identifierName": "Model" }, "name": "Model", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 1603, "end": 173703, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 4008, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 1608, "end": 1688, "loc": { "start": { "line": 41, "column": 2 }, "end": { "line": 43, "column": 3 } }, "computed": false, "key": { "type": "Identifier", "start": 1619, "end": 1633, "loc": { "start": { "line": 41, "column": 13 }, "end": { "line": 41, "column": 27 }, "identifierName": "QueryInterface" }, "name": "QueryInterface" }, "static": true, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1636, "end": 1688, "loc": { "start": { "line": 41, "column": 30 }, "end": { "line": 43, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 1642, "end": 1684, "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 42, "column": 46 } }, "argument": { "type": "CallExpression", "start": 1649, "end": 1683, "loc": { "start": { "line": 42, "column": 11 }, "end": { "line": 42, "column": 45 } }, "callee": { "type": "MemberExpression", "start": 1649, "end": 1681, "loc": { "start": { "line": 42, "column": 11 }, "end": { "line": 42, "column": 43 } }, "object": { "type": "MemberExpression", "start": 1649, "end": 1663, "loc": { "start": { "line": 42, "column": 11 }, "end": { "line": 42, "column": 25 } }, "object": { "type": "ThisExpression", "start": 1649, "end": 1653, "loc": { "start": {