sequelize
Version:
Multi dialect ORM for Node.JS/io.js
1,540 lines (1,539 loc) • 1.33 MB
JSON
{
"type": "File",
"start": 0,
"end": 7355,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 236,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 7355,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 236,
"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": 165,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 46
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 125,
"end": 164,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 45
}
},
"id": {
"type": "Identifier",
"start": 125,
"end": 136,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 17
},
"identifierName": "Transaction"
},
"name": "Transaction"
},
"init": {
"type": "CallExpression",
"start": 139,
"end": 164,
"loc": {
"start": {
"line": 6,
"column": 20
},
"end": {
"line": 6,
"column": 45
}
},
"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": 163,
"loc": {
"start": {
"line": 6,
"column": 28
},
"end": {
"line": 6,
"column": 44
}
},
"extra": {
"rawValue": "../transaction",
"raw": "'../transaction'"
},
"value": "../transaction"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 166,
"end": 204,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 38
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 172,
"end": 203,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 172,
"end": 183,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 17
},
"identifierName": "Association"
},
"name": "Association"
},
"init": {
"type": "CallExpression",
"start": 186,
"end": 203,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 37
}
},
"callee": {
"type": "Identifier",
"start": 186,
"end": 193,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 27
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 194,
"end": 202,
"loc": {
"start": {
"line": 7,
"column": 28
},
"end": {
"line": 7,
"column": 36
}
},
"extra": {
"rawValue": "./base",
"raw": "'./base'"
},
"value": "./base"
}
]
}
}
],
"kind": "const",
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * One-to-one association\n *\n * In the API reference below, add the name of the association to the method, e.g. for `User.belongsTo(Project)` the getter will be `user.getProject()`.\n *\n * @see {@link Model.belongsTo}\n ",
"start": 206,
"end": 430,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 15,
"column": 3
}
}
}
]
},
{
"type": "ClassDeclaration",
"start": 431,
"end": 7251,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 231,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 437,
"end": 446,
"loc": {
"start": {
"line": 16,
"column": 6
},
"end": {
"line": 16,
"column": 15
},
"identifierName": "BelongsTo"
},
"name": "BelongsTo",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 455,
"end": 466,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 35
},
"identifierName": "Association"
},
"name": "Association"
},
"body": {
"type": "ClassBody",
"start": 467,
"end": 7251,
"loc": {
"start": {
"line": 16,
"column": 36
},
"end": {
"line": 231,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 471,
"end": 2338,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 73,
"column": 3
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 471,
"end": 482,
"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": 483,
"end": 489,
"loc": {
"start": {
"line": 17,
"column": 14
},
"end": {
"line": 17,
"column": 20
},
"identifierName": "source"
},
"name": "source"
},
{
"type": "Identifier",
"start": 491,
"end": 497,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 28
},
"identifierName": "target"
},
"name": "target"
},
{
"type": "Identifier",
"start": 499,
"end": 506,
"loc": {
"start": {
"line": 17,
"column": 30
},
"end": {
"line": 17,
"column": 37
},
"identifierName": "options"
},
"name": "options"
}
],
"body": {
"type": "BlockStatement",
"start": 508,
"end": 2338,
"loc": {
"start": {
"line": 17,
"column": 39
},
"end": {
"line": 73,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 514,
"end": 545,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 35
}
},
"expression": {
"type": "CallExpression",
"start": 514,
"end": 544,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 34
}
},
"callee": {
"type": "Super",
"start": 514,
"end": 519,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 9
}
}
},
"arguments": [
{
"type": "Identifier",
"start": 520,
"end": 526,
"loc": {
"start": {
"line": 18,
"column": 10
},
"end": {
"line": 18,
"column": 16
},
"identifierName": "source"
},
"name": "source"
},
{
"type": "Identifier",
"start": 528,
"end": 534,
"loc": {
"start": {
"line": 18,
"column": 18
},
"end": {
"line": 18,
"column": 24
},
"identifierName": "target"
},
"name": "target"
},
{
"type": "Identifier",
"start": 536,
"end": 543,
"loc": {
"start": {
"line": 18,
"column": 26
},
"end": {
"line": 18,
"column": 33
},
"identifierName": "options"
},
"name": "options"
}
]
}
},
{
"type": "ExpressionStatement",
"start": 551,
"end": 586,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 39
}
},
"expression": {
"type": "AssignmentExpression",
"start": 551,
"end": 585,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 38
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 551,
"end": 571,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 24
}
},
"object": {
"type": "ThisExpression",
"start": 551,
"end": 555,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 556,
"end": 571,
"loc": {
"start": {
"line": 20,
"column": 9
},
"end": {
"line": 20,
"column": 24
},
"identifierName": "associationType"
},
"name": "associationType"
},
"computed": false
},
"right": {
"type": "StringLiteral",
"start": 574,
"end": 585,
"loc": {
"start": {
"line": 20,
"column": 27
},
"end": {
"line": 20,
"column": 38
}
},
"extra": {
"rawValue": "BelongsTo",
"raw": "'BelongsTo'"
},
"value": "BelongsTo"
}
}
},
{
"type": "ExpressionStatement",
"start": 591,
"end": 623,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 36
}
},
"expression": {
"type": "AssignmentExpression",
"start": 591,
"end": 622,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 35
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 591,
"end": 615,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 591,
"end": 595,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 596,
"end": 615,
"loc": {
"start": {
"line": 21,
"column": 9
},
"end": {
"line": 21,
"column": 28
},
"identifierName": "isSingleAssociation"
},
"name": "isSingleAssociation"
},
"computed": false
},
"right": {
"type": "BooleanLiteral",
"start": 618,
"end": 622,
"loc": {
"start": {
"line": 21,
"column": 31
},
"end": {
"line": 21,
"column": 35
}
},
"value": true
}
}
},
{
"type": "ExpressionStatement",
"start": 628,
"end": 658,
"loc": {
"start": {
"line": 22,
"column": 4
},
"end": {
"line": 22,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 628,
"end": 657,
"loc": {
"start": {
"line": 22,
"column": 4
},
"end": {
"line": 22,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 628,
"end": 652,
"loc": {
"start": {
"line": 22,
"column": 4
},
"end": {
"line": 22,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 628,
"end": 632,
"loc": {
"start": {
"line": 22,
"column": 4
},
"end": {
"line": 22,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 633,
"end": 652,
"loc": {
"start": {
"line": 22,
"column": 9
},
"end": {
"line": 22,
"column": 28
},
"identifierName": "foreignKeyAttribute"
},
"name": "foreignKeyAttribute"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 655,
"end": 657,
"loc": {
"start": {
"line": 22,
"column": 31
},
"end": {
"line": 22,
"column": 33
}
},
"properties": []
}
}
},
{
"type": "IfStatement",
"start": 664,
"end": 892,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 32,
"column": 5
}
},
"test": {
"type": "MemberExpression",
"start": 668,
"end": 675,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 668,
"end": 672,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 673,
"end": 675,
"loc": {
"start": {
"line": 24,
"column": 13
},
"end": {
"line": 24,
"column": 15
},
"identifierName": "as"
},
"name": "as"
},
"computed": false
},
"consequent": {
"type": "BlockStatement",
"start": 677,
"end": 776,
"loc": {
"start": {
"line": 24,
"column": 17
},
"end": {
"line": 29,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 685,
"end": 707,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 28
}
},
"expression": {
"type": "AssignmentExpression",
"start": 685,
"end": 706,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 27
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 685,
"end": 699,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 20
}
},
"object": {
"type": "ThisExpression",
"start": 685,
"end": 689,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 10
}
}
},
"property": {
"type": "Identifier",
"start": 690,
"end": 699,
"loc": {
"start": {
"line": 25,
"column": 11
},
"end": {
"line": 25,
"column": 20
},
"identifierName": "isAliased"
},
"name": "isAliased"
},
"computed": false
},
"right": {
"type": "BooleanLiteral",
"start": 702,
"end": 706,
"loc": {
"start": {
"line": 25,
"column": 23
},
"end": {
"line": 25,
"column": 27
}
},
"value": true
}
}
},
{
"type": "ExpressionStatement",
"start": 714,
"end": 770,
"loc": {
"start": {
"line": 26,
"column": 6
},
"end": {
"line": 28,
"column": 8
}
},
"expression": {
"type": "AssignmentExpression",
"start": 714,
"end": 769,
"loc": {
"start": {
"line": 26,
"column": 6
},
"end": {
"line": 28,
"column": 7
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 714,
"end": 731,
"loc": {
"start": {
"line": 26,
"column": 6
},
"end": {
"line": 26,
"column": 23
}
},
"object": {
"type": "MemberExpression",
"start": 714,
"end": 726,
"loc": {
"start": {
"line": 26,
"column": 6
},
"end": {
"line": 26,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 714,
"end": 718,
"loc": {
"start": {
"line": 26,
"column": 6
},
"end": {
"line": 26,
"column": 10
}
}
},
"property": {
"type": "Identifier",
"start": 719,
"end": 726,
"loc": {
"start": {
"line": 26,
"column": 11
},
"end": {
"line": 26,
"column": 18
},
"identifierName": "options"
},
"name": "options"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 727,
"end": 731,
"loc": {
"start": {
"line": 26,
"column": 19
},
"end": {
"line": 26,
"column": 23
},
"identifierName": "name"
},
"name": "name"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 734,
"end": 769,
"loc": {
"start": {
"line": 26,
"column": 26
},
"end": {
"line": 28,
"column": 7
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 744,
"end": 761,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 25
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 744,
"end": 752,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 16
},
"identifierName": "singular"
},
"name": "singular"
},
"value": {
"type": "MemberExpression",
"start": 754,
"end": 761,
"loc": {
"start": {
"line": 27,
"column": 18
},
"end": {
"line": 27,
"column": 25
}
},
"object": {
"type": "ThisExpression",
"start": 754,
"end": 758,
"loc": {
"start": {
"line": 27,
"column": 18
},
"end": {
"line": 27,
"column": 22
}
}
},
"property": {
"type": "Identifier",
"start": 759,
"end": 761,
"loc": {
"start": {
"line": 27,
"column": 23
},
"end": {
"line": 27,
"column": 25
},
"identifierName": "as"
},
"name": "as"
},
"computed": false
}
}
]
}
}
}
],
"directives": []
},
"alternate": {
"type": "BlockStatement",
"start": 782,
"end": 892,
"loc": {
"start": {
"line": 29,
"column": 11
},
"end": {
"line": 32,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 790,
"end": 834,
"loc": {
"start": {
"line": 30,
"column": 6
},
"end": {
"line": 30,
"column": 50