UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,475 lines (1,474 loc) 715 kB
{ "type": "File", "start": 0, "end": 4057, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 109, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 4057, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 109, "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": 80, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 28 } }, "declarations": [ { "type": "VariableDeclarator", "start": 58, "end": 79, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 27 } }, "id": { "type": "Identifier", "start": 58, "end": 59, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 7 }, "identifierName": "_" }, "name": "_" }, "init": { "type": "CallExpression", "start": 62, "end": 79, "loc": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 27 } }, "callee": { "type": "Identifier", "start": 62, "end": 69, "loc": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 17 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 70, "end": 78, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 4, "column": 26 } }, "extra": { "rawValue": "lodash", "raw": "'lodash'" }, "value": "lodash" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 81, "end": 117, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 36 } }, "declarations": [ { "type": "VariableDeclarator", "start": 87, "end": 116, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 35 } }, "id": { "type": "Identifier", "start": 87, "end": 93, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 12 }, "identifierName": "HasOne" }, "name": "HasOne" }, "init": { "type": "CallExpression", "start": 96, "end": 116, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 5, "column": 35 } }, "callee": { "type": "Identifier", "start": 96, "end": 103, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 5, "column": 22 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 104, "end": 115, "loc": { "start": { "line": 5, "column": 23 }, "end": { "line": 5, "column": 34 } }, "extra": { "rawValue": "./has-one", "raw": "'./has-one'" }, "value": "./has-one" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 118, "end": 156, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 38 } }, "declarations": [ { "type": "VariableDeclarator", "start": 124, "end": 155, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 37 } }, "id": { "type": "Identifier", "start": 124, "end": 131, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 13 }, "identifierName": "HasMany" }, "name": "HasMany" }, "init": { "type": "CallExpression", "start": 134, "end": 155, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 37 } }, "callee": { "type": "Identifier", "start": 134, "end": 141, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 23 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 142, "end": 154, "loc": { "start": { "line": 6, "column": 24 }, "end": { "line": 6, "column": 36 } }, "extra": { "rawValue": "./has-many", "raw": "'./has-many'" }, "value": "./has-many" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 157, "end": 208, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 51 } }, "declarations": [ { "type": "VariableDeclarator", "start": 163, "end": 207, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 50 } }, "id": { "type": "Identifier", "start": 163, "end": 176, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 19 }, "identifierName": "BelongsToMany" }, "name": "BelongsToMany" }, "init": { "type": "CallExpression", "start": 179, "end": 207, "loc": { "start": { "line": 7, "column": 22 }, "end": { "line": 7, "column": 50 } }, "callee": { "type": "Identifier", "start": 179, "end": 186, "loc": { "start": { "line": 7, "column": 22 }, "end": { "line": 7, "column": 29 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 187, "end": 206, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 49 } }, "extra": { "rawValue": "./belongs-to-many", "raw": "'./belongs-to-many'" }, "value": "./belongs-to-many" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 209, "end": 251, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 42 } }, "declarations": [ { "type": "VariableDeclarator", "start": 215, "end": 250, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 41 } }, "id": { "type": "Identifier", "start": 215, "end": 224, "loc": { "start": { "line": 8, "column": 6 }, "end": { "line": 8, "column": 15 }, "identifierName": "BelongsTo" }, "name": "BelongsTo" }, "init": { "type": "CallExpression", "start": 227, "end": 250, "loc": { "start": { "line": 8, "column": 18 }, "end": { "line": 8, "column": 41 } }, "callee": { "type": "Identifier", "start": 227, "end": 234, "loc": { "start": { "line": 8, "column": 18 }, "end": { "line": 8, "column": 25 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 235, "end": 249, "loc": { "start": { "line": 8, "column": 26 }, "end": { "line": 8, "column": 40 } }, "extra": { "rawValue": "./belongs-to", "raw": "'./belongs-to'" }, "value": "./belongs-to" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 253, "end": 2896, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 75, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 259, "end": 2895, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 75, "column": 1 } }, "id": { "type": "Identifier", "start": 259, "end": 264, "loc": { "start": { "line": 10, "column": 6 }, "end": { "line": 10, "column": 11 }, "identifierName": "Mixin" }, "name": "Mixin" }, "init": { "type": "ObjectExpression", "start": 267, "end": 2895, "loc": { "start": { "line": 10, "column": 14 }, "end": { "line": 75, "column": 1 } }, "properties": [ { "type": "ObjectMethod", "start": 271, "end": 1192, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 33, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 271, "end": 278, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 9 }, "identifierName": "hasMany" }, "name": "hasMany" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 279, "end": 285, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 16 }, "identifierName": "target" }, "name": "target" }, { "type": "Identifier", "start": 287, "end": 294, "loc": { "start": { "line": 11, "column": 18 }, "end": { "line": 11, "column": 25 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 296, "end": 1192, "loc": { "start": { "line": 11, "column": 27 }, "end": { "line": 33, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 327, "end": 523, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 14, "column": 5 } }, "test": { "type": "LogicalExpression", "start": 331, "end": 403, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 80 } }, "left": { "type": "UnaryExpression", "start": 331, "end": 348, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 25 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 332, "end": 348, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 25 } }, "object": { "type": "Identifier", "start": 332, "end": 338, "loc": { "start": { "line": 12, "column": 9 }, "end": { "line": 12, "column": 15 }, "identifierName": "target" }, "name": "target", "leadingComments": null }, "property": { "type": "Identifier", "start": 339, "end": 348, "loc": { "start": { "line": 12, "column": 16 }, "end": { "line": 12, "column": 25 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false, "leadingComments": null }, "extra": { "parenthesizedArgument": false }, "leadingComments": null }, "operator": "||", "right": { "type": "UnaryExpression", "start": 352, "end": 403, "loc": { "start": { "line": 12, "column": 29 }, "end": { "line": 12, "column": 80 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 354, "end": 402, "loc": { "start": { "line": 12, "column": 31 }, "end": { "line": 12, "column": 79 } }, "left": { "type": "MemberExpression", "start": 354, "end": 370, "loc": { "start": { "line": 12, "column": 31 }, "end": { "line": 12, "column": 47 } }, "object": { "type": "Identifier", "start": 354, "end": 360, "loc": { "start": { "line": 12, "column": 31 }, "end": { "line": 12, "column": 37 }, "identifierName": "target" }, "name": "target" }, "property": { "type": "Identifier", "start": 361, "end": 370, "loc": { "start": { "line": 12, "column": 38 }, "end": { "line": 12, "column": 47 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false }, "operator": "instanceof", "right": { "type": "MemberExpression", "start": 382, "end": 402, "loc": { "start": { "line": 12, "column": 59 }, "end": { "line": 12, "column": 79 } }, "object": { "type": "MemberExpression", "start": 382, "end": 396, "loc": { "start": { "line": 12, "column": 59 }, "end": { "line": 12, "column": 73 } }, "object": { "type": "ThisExpression", "start": 382, "end": 386, "loc": { "start": { "line": 12, "column": 59 }, "end": { "line": 12, "column": 63 } } }, "property": { "type": "Identifier", "start": 387, "end": 396, "loc": { "start": { "line": 12, "column": 64 }, "end": { "line": 12, "column": 73 }, "identifierName": "sequelize" }, "name": "sequelize" }, "computed": false }, "property": { "type": "Identifier", "start": 397, "end": 402, "loc": { "start": { "line": 12, "column": 74 }, "end": { "line": 12, "column": 79 }, "identifierName": "Model" }, "name": "Model" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 353 } }, "extra": { "parenthesizedArgument": false } }, "leadingComments": null }, "consequent": { "type": "BlockStatement", "start": 405, "end": 523, "loc": { "start": { "line": 12, "column": 82 }, "end": { "line": 14, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 413, "end": 517, "loc": { "start": { "line": 13, "column": 6 }, "end": { "line": 13, "column": 110 } }, "argument": { "type": "NewExpression", "start": 419, "end": 516, "loc": { "start": { "line": 13, "column": 12 }, "end": { "line": 13, "column": 109 } }, "callee": { "type": "Identifier", "start": 423, "end": 428, "loc": { "start": { "line": 13, "column": 16 }, "end": { "line": 13, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "BinaryExpression", "start": 429, "end": 515, "loc": { "start": { "line": 13, "column": 22 }, "end": { "line": 13, "column": 108 } }, "left": { "type": "MemberExpression", "start": 429, "end": 438, "loc": { "start": { "line": 13, "column": 22 }, "end": { "line": 13, "column": 31 } }, "object": { "type": "ThisExpression", "start": 429, "end": 433, "loc": { "start": { "line": 13, "column": 22 }, "end": { "line": 13, "column": 26 } } }, "property": { "type": "Identifier", "start": 434, "end": 438, "loc": { "start": { "line": 13, "column": 27 }, "end": { "line": 13, "column": 31 }, "identifierName": "name" }, "name": "name" }, "computed": false }, "operator": "+", "right": { "type": "StringLiteral", "start": 441, "end": 515, "loc": { "start": { "line": 13, "column": 34 }, "end": { "line": 13, "column": 108 } }, "extra": { "rawValue": ".hasMany called with something that's not a subclass of Sequelize.Model", "raw": "'.hasMany called with something that\\'s not a subclass of Sequelize.Model'" }, "value": ".hasMany called with something that's not a subclass of Sequelize.Model" } } ] } } ], "directives": [] }, "alternate": null, "leadingComments": [ { "type": "CommentLine", "value": " testhint options:none", "start": 298, "end": 322, "loc": { "start": { "line": 11, "column": 29 }, "end": { "line": 11, "column": 53 } } } ] }, { "type": "VariableDeclaration", "start": 529, "end": 549, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 24 } }, "declarations": [ { "type": "VariableDeclarator", "start": 535, "end": 548, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 23 } }, "id": { "type": "Identifier", "start": 535, "end": 541, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 16 }, "identifierName": "source" }, "name": "source" }, "init": { "type": "ThisExpression", "start": 544, "end": 548, "loc": { "start": { "line": 16, "column": 19 }, "end": { "line": 16, "column": 23 } } } } ], "kind": "const", "trailingComments": [ { "type": "CommentLine", "value": " Since this is a mixin, we'll need a unique letiable name for hooks (since Model will override our hooks option)", "start": 555, "end": 669, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 118 } } } ] }, { "type": "ExpressionStatement", "start": 674, "end": 698, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 28 } }, "expression": { "type": "AssignmentExpression", "start": 674, "end": 697, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 27 } }, "operator": "=", "left": { "type": "Identifier", "start": 674, "end": 681, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 11 }, "identifierName": "options" }, "name": "options", "leadingComments": null }, "right": { "type": "LogicalExpression", "start": 684, "end": 697, "loc": { "start": { "line": 19, "column": 14 }, "end": { "line": 19, "column": 27 } }, "left": { "type": "Identifier", "start": 684, "end": 691, "loc": { "start": { "line": 19, "column": 14 }, "end": { "line": 19, "column": 21 }, "identifierName": "options" }, "name": "options" }, "operator": "||", "right": { "type": "ObjectExpression", "start": 695, "end": 697, "loc": { "start": { "line": 19, "column": 25 }, "end": { "line": 19, "column": 27 } }, "properties": [] } }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " Since this is a mixin, we'll need a unique letiable name for hooks (since Model will override our hooks option)", "start": 555, "end": 669, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 118 } } } ] }, { "type": "ExpressionStatement", "start": 703, "end": 780, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 81 } }, "expression": { "type": "AssignmentExpression", "start": 703, "end": 779, "loc": { "start": { "line": 20, "column": 4 },