sequelize
Version:
Multi dialect ORM for Node.JS/io.js
1,591 lines (1,590 loc) • 2.79 MB
JSON
{
"type": "File",
"start": 0,
"end": 15268,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 468,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 15268,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 468,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "VariableDeclaration",
"start": 34,
"end": 71,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 37
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 40,
"end": 70,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 40,
"end": 45,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 11
},
"identifierName": "Utils"
},
"name": "Utils",
"leadingComments": null
},
"init": {
"type": "CallExpression",
"start": 48,
"end": 70,
"loc": {
"start": {
"line": 4,
"column": 14
},
"end": {
"line": 4,
"column": 36
}
},
"callee": {
"type": "Identifier",
"start": 48,
"end": 55,
"loc": {
"start": {
"line": 4,
"column": 14
},
"end": {
"line": 4,
"column": 21
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 56,
"end": 69,
"loc": {
"start": {
"line": 4,
"column": 22
},
"end": {
"line": 4,
"column": 35
}
},
"extra": {
"rawValue": "../../utils",
"raw": "'../../utils'"
},
"value": "../../utils"
}
]
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": " jshint -W110 ",
"start": 15,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 18
}
}
}
]
},
{
"type": "VariableDeclaration",
"start": 72,
"end": 101,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 29
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 78,
"end": 100,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 78,
"end": 82,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 10
},
"identifierName": "util"
},
"name": "util"
},
"init": {
"type": "CallExpression",
"start": 85,
"end": 100,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 28
}
},
"callee": {
"type": "Identifier",
"start": 85,
"end": 92,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 20
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 93,
"end": 99,
"loc": {
"start": {
"line": 5,
"column": 21
},
"end": {
"line": 5,
"column": 27
}
},
"extra": {
"rawValue": "util",
"raw": "'util'"
},
"value": "util"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 102,
"end": 151,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 49
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 108,
"end": 150,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 48
}
},
"id": {
"type": "Identifier",
"start": 108,
"end": 119,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 17
},
"identifierName": "Transaction"
},
"name": "Transaction"
},
"init": {
"type": "CallExpression",
"start": 122,
"end": 150,
"loc": {
"start": {
"line": 6,
"column": 20
},
"end": {
"line": 6,
"column": 48
}
},
"callee": {
"type": "Identifier",
"start": 122,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 20
},
"end": {
"line": 6,
"column": 27
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 130,
"end": 149,
"loc": {
"start": {
"line": 6,
"column": 28
},
"end": {
"line": 6,
"column": 47
}
},
"extra": {
"rawValue": "../../transaction",
"raw": "'../../transaction'"
},
"value": "../../transaction"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 152,
"end": 180,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 28
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 158,
"end": 179,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 27
}
},
"id": {
"type": "Identifier",
"start": 158,
"end": 159,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 7
},
"identifierName": "_"
},
"name": "_"
},
"init": {
"type": "CallExpression",
"start": 162,
"end": 179,
"loc": {
"start": {
"line": 7,
"column": 10
},
"end": {
"line": 7,
"column": 27
}
},
"callee": {
"type": "Identifier",
"start": 162,
"end": 169,
"loc": {
"start": {
"line": 7,
"column": 10
},
"end": {
"line": 7,
"column": 17
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 170,
"end": 178,
"loc": {
"start": {
"line": 7,
"column": 18
},
"end": {
"line": 7,
"column": 26
}
},
"extra": {
"rawValue": "lodash",
"raw": "'lodash'"
},
"value": "lodash"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 181,
"end": 245,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 8,
"column": 64
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 187,
"end": 244,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 63
}
},
"id": {
"type": "Identifier",
"start": 187,
"end": 206,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 25
},
"identifierName": "MySqlQueryGenerator"
},
"name": "MySqlQueryGenerator"
},
"init": {
"type": "CallExpression",
"start": 209,
"end": 244,
"loc": {
"start": {
"line": 8,
"column": 28
},
"end": {
"line": 8,
"column": 63
}
},
"callee": {
"type": "Identifier",
"start": 209,
"end": 216,
"loc": {
"start": {
"line": 8,
"column": 28
},
"end": {
"line": 8,
"column": 35
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 217,
"end": 243,
"loc": {
"start": {
"line": 8,
"column": 36
},
"end": {
"line": 8,
"column": 62
}
},
"extra": {
"rawValue": "../mysql/query-generator",
"raw": "'../mysql/query-generator'"
},
"value": "../mysql/query-generator"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 246,
"end": 316,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 9,
"column": 70
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 252,
"end": 315,
"loc": {
"start": {
"line": 9,
"column": 6
},
"end": {
"line": 9,
"column": 69
}
},
"id": {
"type": "Identifier",
"start": 252,
"end": 274,
"loc": {
"start": {
"line": 9,
"column": 6
},
"end": {
"line": 9,
"column": 28
},
"identifierName": "AbstractQueryGenerator"
},
"name": "AbstractQueryGenerator"
},
"init": {
"type": "CallExpression",
"start": 277,
"end": 315,
"loc": {
"start": {
"line": 9,
"column": 31
},
"end": {
"line": 9,
"column": 69
}
},
"callee": {
"type": "Identifier",
"start": 277,
"end": 284,
"loc": {
"start": {
"line": 9,
"column": 31
},
"end": {
"line": 9,
"column": 38
},
"identifierName": "require"
},
"name": "require"
},
"arguments": [
{
"type": "StringLiteral",
"start": 285,
"end": 314,
"loc": {
"start": {
"line": 9,
"column": 39
},
"end": {
"line": 9,
"column": 68
}
},
"extra": {
"rawValue": "../abstract/query-generator",
"raw": "'../abstract/query-generator'"
},
"value": "../abstract/query-generator"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 318,
"end": 15233,
"loc": {
"start": {
"line": 11,
"column": 0
},
"end": {
"line": 465,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 324,
"end": 15232,
"loc": {
"start": {
"line": 11,
"column": 6
},
"end": {
"line": 465,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 324,
"end": 338,
"loc": {
"start": {
"line": 11,
"column": 6
},
"end": {
"line": 11,
"column": 20
},
"identifierName": "QueryGenerator"
},
"name": "QueryGenerator"
},
"init": {
"type": "ObjectExpression",
"start": 341,
"end": 15232,
"loc": {
"start": {
"line": 11,
"column": 23
},
"end": {
"line": 465,
"column": 1
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 371,
"end": 401,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 13,
"column": 32
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 371,
"end": 380,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 13,
"column": 11
},
"identifierName": "__proto__"
},
"name": "__proto__",
"leadingComments": null
},
"value": {
"type": "Identifier",
"start": 382,
"end": 401,
"loc": {
"start": {
"line": 13,
"column": 13
},
"end": {
"line": 13,
"column": 32
},
"identifierName": "MySqlQueryGenerator"
},
"name": "MySqlQueryGenerator"
},
"leadingComments": [
{
"type": "CommentBlock",
"value": " jshint proto:true ",
"start": 345,
"end": 368,
"loc": {
"start": {
"line": 12,
"column": 2
},
"end": {
"line": 12,
"column": 25
}
}
}
]
},
{
"type": "ObjectProperty",
"start": 405,
"end": 416,
"loc": {
"start": {
"line": 14,
"column": 2
},
"end": {
"line": 14,
"column": 13
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 405,
"end": 412,
"loc": {
"start": {
"line": 14,
"column": 2
},
"end": {
"line": 14,
"column": 9
},
"identifierName": "options"
},
"name": "options"
},
"value": {
"type": "ObjectExpression",
"start": 414,
"end": 416,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 13
}
},
"properties": []
}
},
{
"type": "ObjectProperty",
"start": 420,
"end": 437,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 19
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 420,
"end": 427,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 9
},
"identifierName": "dialect"
},
"name": "dialect"
},
"value": {
"type": "StringLiteral",
"start": 429,
"end": 437,
"loc": {
"start": {
"line": 15,
"column": 11
},
"end": {
"line": 15,
"column": 19
}
},
"extra": {
"rawValue": "sqlite",
"raw": "'sqlite'"
},
"value": "sqlite"
}
},
{
"type": "ObjectMethod",
"start": 442,
"end": 557,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 19,
"column": 3
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 442,
"end": 454,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 17,
"column": 14
},
"identifierName": "createSchema"
},
"name": "createSchema"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 457,
"end": 557,
"loc": {
"start": {
"line": 17,
"column": 17
},
"end": {
"line": 19,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 463,
"end": 553,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 94
}
},
"argument": {
"type": "StringLiteral",
"start": 470,
"end": 552,
"loc": {
"start": {
"line": 18,
"column": 11
},
"end": {
"line": 18,
"column": 93
}
},
"extra": {
"rawValue": "SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';",
"raw": "\"SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';\""
},
"value": "SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';"
}
}
],
"directives": []
}
},
{
"type": "ObjectMethod",
"start": 562,
"end": 681,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 23,
"column": 3
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 562,
"end": 578,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 18
},
"identifierName": "showSchemasQuery"
},
"name": "showSchemasQuery"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 581,
"end": 681,
"loc": {
"start": {
"line": 21,
"column": 21
},
"end": {
"line": 23,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 587,
"end": 677,
"loc": {
"start": {
"line": 22,
"column": 4
},
"end": {
"line": 22,
"column": 94
}
},
"argument": {
"type": "StringLiteral",
"start": 594,
"end": 676,
"loc": {
"start": {
"line": 22,
"column": 11
},
"end": {
"line": 22,
"column": 93
}
},
"extra": {
"rawValue": "SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';",
"raw": "\"SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';\""
},
"value": "SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';"
}
}
],
"directives": []
}
},
{
"type": "ObjectMethod",
"start": 686,
"end": 757,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 27,
"column": 3
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 686,
"end": 698,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 25,
"column": 14
},
"identifierName": "versionQuery"
},
"name": "versionQuery"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 701,
"end": 757,
"loc": {
"start": {
"line": 25,
"column": 17
},
"end": {
"line": 27,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 707,
"end": 753,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 26,
"column": 50
}
},
"argument": {
"type": "StringLiteral",
"start": 714,
"end": 752,
"loc": {
"start": {
"line": 26,
"column": 11
},
"end": {
"line": 26,
"column": 49
}
},
"extra": {
"rawValue": "SELECT sqlite_version() as `version`",
"raw": "'SELECT sqlite_version() as `version`'"
},
"value": "SELECT sqlite_version() as `version`"
}
}
],
"directives": []
}
},
{
"type": "ObjectMethod",
"start": 762,
"end": 2720,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 78,
"column": 3
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 762,
"end": 778,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 29,
"column": 18
},
"identifierName": "createTableQuery"
},
"name": "createTableQuery"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 779,
"end": 788,
"loc": {
"start": {
"line": 29,
"column": 19
},
"end": {
"line": 29,
"column": 28
},
"identifierName": "tableName"
},
"name": "tableName"
},
{
"type": "Identifier",
"start": 790,
"end": 800,
"loc": {
"start": {
"line": 29,
"column": 30
},
"end": {
"line": 29,
"column": 40
},
"identifierName": "attributes"
},
"name": "attributes"
},
{
"type": "Identifier",
"start": 802,
"end": 809,
"loc": {
"start": {
"line": 29,
"column": 42
},
"end": {
"line": 29,
"column": 49
},
"identifierName": "options"
},
"name": "options"
}
],
"body": {
"type": "BlockStatement",
"start": 811,
"end": 2720,
"loc": {
"start": {
"line": 29,
"column": 51
},
"end": {
"line": 78,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 817,
"end": 841,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 28
}
},
"expression": {
"type": "AssignmentExpression",
"start": 817,
"end": 840,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 27
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 817,
"end": 824,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 11
},
"identifierName": "options"
},
"name": "options"
},
"right": {
"type": "LogicalExpression",
"start": 827,
"end": 840,
"loc": {
"start": {
"line": 30,
"column": 14
},
"end": {
"line": 30,
"column": 27
}
},
"left": {
"type": "Identifier",
"start": 827,
"end": 834,
"loc": {
"start": {
"line": 30,
"column": 14
},
"end": {
"line": 30,
"column": 21
},
"identifierName": "options"
},
"name": "options"
},
"operator": "||",
"right": {
"type": "ObjectExpression",
"start": 838,
"end": 840,
"loc": {
"start": {
"line": 30,
"column": 25
},
"end": {
"line": 30,
"column": 27
}
},
"properties": []
}
}
}
},
{
"type": "VariableDeclaration",
"start": 847,
"end": 870,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 27
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 853,
"end": 869,
"loc": {
"start": {
"line": 32,
"column": 10
},
"end": {
"line": 32,
"column": 26
}
},
"id": {
"type": "Identifier",
"start": 853,
"end": 864,
"loc": {
"start": {
"line": 32,
"column": 10
},
"end": {
"line": 32,
"column": 21
},
"identifierName": "primaryKeys"
},
"name": "primaryKeys"
},
"init": {
"type": "ArrayExpression",
"start": 867,
"end": 869,
"loc": {
"start": {
"line": 32,
"column": 24
},
"end": {
"line": 32,
"column": 26
}
},
"elements": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 875,
"end": 1008,
"loc": {
"start": {
"line": 33,
"column": 4
},
"end": {
"line": 33,
"column": 137
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 881,
"end": 1007,
"loc": {
"start": {
"line": 33,
"column": 10
},
"end": {
"line": 33,
"column": 136
}
},
"id": {
"type": "Identifier",
"start": 881,
"end": 905,
"loc": {
"start": {
"line": 33,
"column": 10
},
"end": {
"line": 33,
"column": 34
},
"identifierName": "needsMultiplePrimaryKeys"
},
"name": "needsMultiplePrimaryKeys"
},
"init": {
"type": "BinaryExpression",
"start": 909,
"end": 1006,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {
"line": 33,
"column": 135
}
},
"left": {
"type": "MemberExpression",
"start": 909,
"end": 1002,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {
"line": 33,
"column": 131
}
},
"object": {
"type": "CallExpression",
"start": 909,
"end": 995,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {
"line": 33,
"column": 124
}
},
"callee": {
"type": "MemberExpression",
"start": 909,
"end": 942,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {
"line": 33,
"column": 71
}
},
"object": {
"type": "CallExpression",
"start": 909,
"end": 935,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {
"line": 33,
"column": 64
}
},
"callee": {
"type": "MemberExpression",
"start": 909,
"end": 923,
"loc": {
"start": {
"line": 33,
"column": 38
},
"end": {