sequelize
Version:
Multi dialect ORM for Node.JS/io.js
1,449 lines (1,448 loc) • 413 kB
JSON
{
"type": "File",
"start": 0,
"end": 2533,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 75,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2533,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 75,
"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": "FunctionDeclaration",
"start": 53,
"end": 449,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 13,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 62,
"end": 82,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 29
},
"identifierName": "checkNamingCollision"
},
"name": "checkNamingCollision"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 83,
"end": 94,
"loc": {
"start": {
"line": 5,
"column": 30
},
"end": {
"line": 5,
"column": 41
},
"identifierName": "association"
},
"name": "association"
}
],
"body": {
"type": "BlockStatement",
"start": 96,
"end": 449,
"loc": {
"start": {
"line": 5,
"column": 43
},
"end": {
"line": 13,
"column": 1
}
},
"body": [
{
"type": "IfStatement",
"start": 100,
"end": 447,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 12,
"column": 3
}
},
"test": {
"type": "CallExpression",
"start": 104,
"end": 167,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 69
}
},
"callee": {
"type": "MemberExpression",
"start": 104,
"end": 151,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 53
}
},
"object": {
"type": "MemberExpression",
"start": 104,
"end": 136,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 38
}
},
"object": {
"type": "MemberExpression",
"start": 104,
"end": 122,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 24
}
},
"object": {
"type": "Identifier",
"start": 104,
"end": 115,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 17
},
"identifierName": "association"
},
"name": "association"
},
"property": {
"type": "Identifier",
"start": 116,
"end": 122,
"loc": {
"start": {
"line": 6,
"column": 18
},
"end": {
"line": 6,
"column": 24
},
"identifierName": "source"
},
"name": "source"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 123,
"end": 136,
"loc": {
"start": {
"line": 6,
"column": 25
},
"end": {
"line": 6,
"column": 38
},
"identifierName": "rawAttributes"
},
"name": "rawAttributes"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 137,
"end": 151,
"loc": {
"start": {
"line": 6,
"column": 39
},
"end": {
"line": 6,
"column": 53
},
"identifierName": "hasOwnProperty"
},
"name": "hasOwnProperty"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 152,
"end": 166,
"loc": {
"start": {
"line": 6,
"column": 54
},
"end": {
"line": 6,
"column": 68
}
},
"object": {
"type": "Identifier",
"start": 152,
"end": 163,
"loc": {
"start": {
"line": 6,
"column": 54
},
"end": {
"line": 6,
"column": 65
},
"identifierName": "association"
},
"name": "association"
},
"property": {
"type": "Identifier",
"start": 164,
"end": 166,
"loc": {
"start": {
"line": 6,
"column": 66
},
"end": {
"line": 6,
"column": 68
},
"identifierName": "as"
},
"name": "as"
},
"computed": false
}
]
},
"consequent": {
"type": "BlockStatement",
"start": 169,
"end": 447,
"loc": {
"start": {
"line": 6,
"column": 71
},
"end": {
"line": 12,
"column": 3
}
},
"body": [
{
"type": "ThrowStatement",
"start": 175,
"end": 443,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 11,
"column": 6
}
},
"argument": {
"type": "NewExpression",
"start": 181,
"end": 442,
"loc": {
"start": {
"line": 7,
"column": 10
},
"end": {
"line": 11,
"column": 5
}
},
"callee": {
"type": "Identifier",
"start": 185,
"end": 190,
"loc": {
"start": {
"line": 7,
"column": 14
},
"end": {
"line": 7,
"column": 19
},
"identifierName": "Error"
},
"name": "Error"
},
"arguments": [
{
"type": "BinaryExpression",
"start": 198,
"end": 436,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 10,
"column": 87
}
},
"left": {
"type": "BinaryExpression",
"start": 198,
"end": 346,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 9,
"column": 89
}
},
"left": {
"type": "BinaryExpression",
"start": 198,
"end": 320,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 9,
"column": 63
}
},
"left": {
"type": "BinaryExpression",
"start": 198,
"end": 303,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 9,
"column": 46
}
},
"left": {
"type": "BinaryExpression",
"start": 198,
"end": 286,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 9,
"column": 29
}
},
"left": {
"type": "BinaryExpression",
"start": 198,
"end": 254,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 62
}
},
"left": {
"type": "StringLiteral",
"start": 198,
"end": 237,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 45
}
},
"extra": {
"rawValue": "Naming collision between attribute '",
"raw": "'Naming collision between attribute \\''"
},
"value": "Naming collision between attribute '"
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start": 240,
"end": 254,
"loc": {
"start": {
"line": 8,
"column": 48
},
"end": {
"line": 8,
"column": 62
}
},
"object": {
"type": "Identifier",
"start": 240,
"end": 251,
"loc": {
"start": {
"line": 8,
"column": 48
},
"end": {
"line": 8,
"column": 59
},
"identifierName": "association"
},
"name": "association"
},
"property": {
"type": "Identifier",
"start": 252,
"end": 254,
"loc": {
"start": {
"line": 8,
"column": 60
},
"end": {
"line": 8,
"column": 62
},
"identifierName": "as"
},
"name": "as"
},
"computed": false
}
},
"operator": "+",
"right": {
"type": "StringLiteral",
"start": 263,
"end": 286,
"loc": {
"start": {
"line": 9,
"column": 6
},
"end": {
"line": 9,
"column": 29
}
},
"extra": {
"rawValue": "' and association '",
"raw": "'\\' and association \\''"
},
"value": "' and association '"
}
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start": 289,
"end": 303,
"loc": {
"start": {
"line": 9,
"column": 32
},
"end": {
"line": 9,
"column": 46
}
},
"object": {
"type": "Identifier",
"start": 289,
"end": 300,
"loc": {
"start": {
"line": 9,
"column": 32
},
"end": {
"line": 9,
"column": 43
},
"identifierName": "association"
},
"name": "association"
},
"property": {
"type": "Identifier",
"start": 301,
"end": 303,
"loc": {
"start": {
"line": 9,
"column": 44
},
"end": {
"line": 9,
"column": 46
},
"identifierName": "as"
},
"name": "as"
},
"computed": false
}
},
"operator": "+",
"right": {
"type": "StringLiteral",
"start": 306,
"end": 320,
"loc": {
"start": {
"line": 9,
"column": 49
},
"end": {
"line": 9,
"column": 63
}
},
"extra": {
"rawValue": "' on model ",
"raw": "'\\' on model '"
},
"value": "' on model "
}
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start": 323,
"end": 346,
"loc": {
"start": {
"line": 9,
"column": 66
},
"end": {
"line": 9,
"column": 89
}
},
"object": {
"type": "MemberExpression",
"start": 323,
"end": 341,
"loc": {
"start": {
"line": 9,
"column": 66
},
"end": {
"line": 9,
"column": 84
}
},
"object": {
"type": "Identifier",
"start": 323,
"end": 334,
"loc": {
"start": {
"line": 9,
"column": 66
},
"end": {
"line": 9,
"column": 77
},
"identifierName": "association"
},
"name": "association"
},
"property": {
"type": "Identifier",
"start": 335,
"end": 341,
"loc": {
"start": {
"line": 9,
"column": 78
},
"end": {
"line": 9,
"column": 84
},
"identifierName": "source"
},
"name": "source"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 342,
"end": 346,
"loc": {
"start": {
"line": 9,
"column": 85
},
"end": {
"line": 9,
"column": 89
},
"identifierName": "name"
},
"name": "name"
},
"computed": false
}
},
"operator": "+",
"right": {
"type": "StringLiteral",
"start": 355,
"end": 436,
"loc": {
"start": {
"line": 10,
"column": 6
},
"end": {
"line": 10,
"column": 87
}
},
"extra": {
"rawValue": ". To remedy this, change either foreignKey or as in your association definition",
"raw": "'. To remedy this, change either foreignKey or as in your association definition'"
},
"value": ". To remedy this, change either foreignKey or as in your association definition"
}
}
]
}
}
],
"directives": []
},
"alternate": null
}
],
"directives": []
}
},
{
"type": "ExpressionStatement",
"start": 450,
"end": 502,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 14,
"column": 52
}
},
"expression": {
"type": "AssignmentExpression",
"start": 450,
"end": 501,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 14,
"column": 51
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 450,
"end": 478,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 14,
"column": 28
}
},
"object": {
"type": "Identifier",
"start": 450,
"end": 457,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 14,
"column": 7
},
"identifierName": "exports"
},
"name": "exports"
},
"property": {
"type": "Identifier",
"start": 458,
"end": 478,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 28
},
"identifierName": "checkNamingCollision"
},
"name": "checkNamingCollision"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 481,
"end": 501,
"loc": {
"start": {
"line": 14,
"column": 31
},
"end": {
"line": 14,
"column": 51
},
"identifierName": "checkNamingCollision"
},
"name": "checkNamingCollision"
}
}
},
{
"type": "FunctionDeclaration",
"start": 504,
"end": 1671,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 45,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 513,
"end": 537,
"loc": {
"start": {
"line": 16,
"column": 9
},
"end": {
"line": 16,
"column": 33
},
"identifierName": "addForeignKeyConstraints"
},
"name": "addForeignKeyConstraints"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 538,
"end": 550,
"loc": {
"start": {
"line": 16,
"column": 34
},
"end": {
"line": 16,
"column": 46
},
"identifierName": "newAttribute"
},
"name": "newAttribute"
},
{
"type": "Identifier",
"start": 552,
"end": 558,
"loc": {
"start": {
"line": 16,
"column": 48
},
"end": {
"line": 16,
"column": 54
},
"identifierName": "source"
},
"name": "source"
},
{
"type": "Identifier",
"start": 560,
"end": 566,
"loc": {
"start": {
"line": 16,
"column": 56
},
"end": {
"line": 16,
"column": 62
},
"identifierName": "target"
},
"name": "target"
},
{
"type": "Identifier",
"start": 568,
"end": 575,
"loc": {
"start": {
"line": 16,
"column": 64
},
"end": {
"line": 16,
"column": 71
},
"identifierName": "options"
},
"name": "options"
},
{
"type": "Identifier",
"start": 577,
"end": 580,
"loc": {
"start": {
"line": 16,
"column": 73
},
"end": {
"line": 16,
"column": 76
},
"identifierName": "key"
},
"name": "key"
}
],
"body": {
"type": "BlockStatement",
"start": 582,
"end": 1671,
"loc": {
"start": {
"line": 16,
"column": 78
},
"end": {
"line": 45,
"column": 1
}
},
"body": [
{
"type": "IfStatement",
"start": 739,
"end": 1669,
"loc": {
"start": {
"line": 20,
"column": 2
},
"end": {
"line": 44,
"column": 3
}
},
"test": {
"type": "LogicalExpression",
"start": 743,
"end": 811,
"loc": {
"start": {
"line": 20,
"column": 6
},
"end": {
"line": 20,
"column": 74
}
},
"left": {
"type": "LogicalExpression",
"start": 743,
"end": 791,
"loc": {
"start": {
"line": 20,
"column": 6
},
"end": {
"line": 20,
"column": 54
}
},
"left": {
"type": "MemberExpression",
"start": 743,
"end": 771,
"loc": {
"start": {
"line": 20,
"column": 6
},
"end": {
"line": 20,
"column": 34
}
},
"object": {
"type": "Identifier",
"start": 743,
"end": 750,
"loc": {
"start": {
"line": 20,
"column": 6
},
"end": {
"line": 20,
"column": 13
},
"identifierName": "options"
},
"name": "options",
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 751,
"end": 771,
"loc": {
"start": {
"line": 20,
"column": 14
},
"end": {
"line": 20,
"column": 34
},
"identifierName": "foreignKeyConstraint"
},
"name": "foreignKeyConstraint"
},
"computed": false,
"leadingComments": null
},
"operator": "||",
"right": {
"type": "MemberExpression",
"start": 775,
"end": 791,
"loc": {
"start": {
"line": 20,
"column": 38
},
"end": {
"line": 20,
"column": 54
}
},
"object": {
"type": "Identifier",
"start": 775,
"end": 782,
"loc": {
"start": {
"line": 20,
"column": 38
},
"end": {
"line": 20,
"column": 45
},
"identifierName": "options"
},
"name": "options"
},
"property": {
"type": "Identifier",
"start": 783,
"end": 791,
"loc": {
"start": {
"line": 20,
"column": 46
},
"end": {
"line": 20,
"column": 54
},
"identifierName": "onDelete"
},
"name": "onDelete"
},
"computed": false
},
"leadingComments": null
},
"operator": "||",
"right": {
"type": "MemberExpression",
"start": 795,
"end": 811,
"loc": {
"start": {
"line": 20,
"column": 58
},
"end": {
"line": 20,
"column": 74
}
},
"object": {
"type": "Identifier",
"start": 795,
"end": 802,
"loc": {
"start": {
"line": 20,
"column": 58
},
"end": {
"line": 20,
"column": 65
},
"identifierName": "options"
},
"name": "options"
},
"property": {
"type": "Identifier",
"start": 803,
"end": 811,
"loc": {
"start": {
"line": 20,
"column": 66
},
"end": {
"line": 20,
"column": 74
},
"identifierName": "onUpdate"
},
"name": "onUpdate"
},
"computed": false
},
"leadingComments": null
},
"consequent": {
"type": "BlockStatement",
"start": 813,
"end": 1669,
"loc": {
"start": {
"line": 20,
"column": 76
},
"end": {
"line": 44,
"column": 3
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 894,
"end": 1082,
"loc": {
"start": {
"line": 23,
"column": 4
},
"end": {
"line": 25,
"column": 66
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 900,
"end": 1081,
"loc": {
"start": {
"line": 23,
"column": 10
},
"end": {
"line": 25,
"column": 65
}
},
"id": {
"type": "Identifier",
"start": 900,
"end": 911,
"loc": {
"start": {
"line": 23,
"column": 10
},
"end": {
"line": 23,
"column": 21
},
"identifierName": "primaryKeys"
},
"name": "primaryKeys",
"leadingComments": null
},
"init": {
"type": "CallExpression",
"start": 914,
"end": 1081,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 25,
"column": 65
}
},
"callee": {
"type": "MemberExpression",
"start": 914,
"end": 1079,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 25,
"column": 63
}
},
"object": {
"type": "CallExpression",
"start": 914,
"end": 1073,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 25,
"column": 57
}
},
"callee": {
"type": "MemberExpression",
"start": 914,
"end": 1026,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 25,
"column": 10
}
},
"object": {
"type": "CallExpression",
"start": 914,
"end": 1015,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 24,
"column": 58
}
},
"callee": {
"type": "MemberExpression",
"start": 914,
"end": 970,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 24,
"column": 13
}
},
"object": {
"type": "CallExpression",
"start": 914,
"end": 956,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 23,
"column": 66
}
},
"callee": {
"type": "MemberExpression",
"start": 914,
"end": 954,
"loc": {
"start": {
"line": 23,
"column": 24
},
"end": {
"line": 23,
"column": 64
}
},
"object": {
"type": "CallExpression",
"start": 914,
"end": 949,
"loc": {
"start": {
"line": 23,
"column": 24
},