UNPKG

sequelize

Version:

Multi dialect ORM for Node.JS/io.js

1,387 lines 2.28 MB
{ "type": "File", "start": 0, "end": 11536, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 355, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 11536, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 355, "column": 0 } }, "sourceType": "module", "body": [ { "type": "VariableDeclaration", "start": 15, "end": 52, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 21, "end": 51, "loc": { "start": { "line": 3, "column": 6 }, "end": { "line": 3, "column": 36 } }, "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": 51, "loc": { "start": { "line": 3, "column": 14 }, "end": { "line": 3, "column": 36 } }, "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": 50, "loc": { "start": { "line": 3, "column": 22 }, "end": { "line": 3, "column": 35 } }, "extra": { "rawValue": "../../utils", "raw": "'../../utils'" }, "value": "../../utils" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 53, "end": 123, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 70 } }, "declarations": [ { "type": "VariableDeclarator", "start": 59, "end": 122, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 69 } }, "id": { "type": "Identifier", "start": 59, "end": 81, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 28 }, "identifierName": "AbstractQueryGenerator" }, "name": "AbstractQueryGenerator" }, "init": { "type": "CallExpression", "start": 84, "end": 122, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 69 } }, "callee": { "type": "Identifier", "start": 84, "end": 91, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 38 }, "identifierName": "require" }, "name": "require" }, "arguments": [ { "type": "StringLiteral", "start": 92, "end": 121, "loc": { "start": { "line": 4, "column": 39 }, "end": { "line": 4, "column": 68 } }, "extra": { "rawValue": "../abstract/query-generator", "raw": "'../abstract/query-generator'" }, "value": "../abstract/query-generator" } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 125, "end": 11398, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 347, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 131, "end": 11397, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 347, "column": 1 } }, "id": { "type": "Identifier", "start": 131, "end": 145, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 20 }, "identifierName": "QueryGenerator" }, "name": "QueryGenerator" }, "init": { "type": "ObjectExpression", "start": 148, "end": 11397, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 347, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 178, "end": 211, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 178, "end": 187, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 11 }, "identifierName": "__proto__" }, "name": "__proto__", "leadingComments": null }, "value": { "type": "Identifier", "start": 189, "end": 211, "loc": { "start": { "line": 8, "column": 13 }, "end": { "line": 8, "column": 35 }, "identifierName": "AbstractQueryGenerator" }, "name": "AbstractQueryGenerator" }, "leadingComments": [ { "type": "CommentBlock", "value": " jshint proto:true ", "start": 152, "end": 175, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 25 } } } ] }, { "type": "ObjectProperty", "start": 215, "end": 231, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 215, "end": 222, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 9 }, "identifierName": "dialect" }, "name": "dialect" }, "value": { "type": "StringLiteral", "start": 224, "end": 231, "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 18 } }, "extra": { "rawValue": "mysql", "raw": "'mysql'" }, "value": "mysql" } }, { "type": "ObjectMethod", "start": 236, "end": 282, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 13, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 236, "end": 248, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 14 }, "identifierName": "createSchema" }, "name": "createSchema" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 251, "end": 282, "loc": { "start": { "line": 11, "column": 17 }, "end": { "line": 13, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 257, "end": 278, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 12, "column": 25 } }, "argument": { "type": "StringLiteral", "start": 264, "end": 277, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 24 } }, "extra": { "rawValue": "SHOW TABLES", "raw": "'SHOW TABLES'" }, "value": "SHOW TABLES" } } ], "directives": [] } }, { "type": "ObjectMethod", "start": 287, "end": 337, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 17, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 287, "end": 303, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 18 }, "identifierName": "showSchemasQuery" }, "name": "showSchemasQuery" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 306, "end": 337, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 17, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 312, "end": 333, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 25 } }, "argument": { "type": "StringLiteral", "start": 319, "end": 332, "loc": { "start": { "line": 16, "column": 11 }, "end": { "line": 16, "column": 24 } }, "extra": { "rawValue": "SHOW TABLES", "raw": "'SHOW TABLES'" }, "value": "SHOW TABLES" } } ], "directives": [] } }, { "type": "ObjectMethod", "start": 342, "end": 406, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 21, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 342, "end": 354, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 14 }, "identifierName": "versionQuery" }, "name": "versionQuery" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 357, "end": 406, "loc": { "start": { "line": 19, "column": 17 }, "end": { "line": 21, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 363, "end": 402, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 43 } }, "argument": { "type": "StringLiteral", "start": 370, "end": 401, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 42 } }, "extra": { "rawValue": "SELECT VERSION() as `version`", "raw": "'SELECT VERSION() as `version`'" }, "value": "SELECT VERSION() as `version`" } } ], "directives": [] } }, { "type": "ObjectMethod", "start": 411, "end": 3556, "loc": { "start": { "line": 23, "column": 2 }, "end": { "line": 96, "column": 3 } }, "method": true, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 411, "end": 427, "loc": { "start": { "line": 23, "column": 2 }, "end": { "line": 23, "column": 18 }, "identifierName": "createTableQuery" }, "name": "createTableQuery" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 428, "end": 437, "loc": { "start": { "line": 23, "column": 19 }, "end": { "line": 23, "column": 28 }, "identifierName": "tableName" }, "name": "tableName" }, { "type": "Identifier", "start": 439, "end": 449, "loc": { "start": { "line": 23, "column": 30 }, "end": { "line": 23, "column": 40 }, "identifierName": "attributes" }, "name": "attributes" }, { "type": "Identifier", "start": 451, "end": 458, "loc": { "start": { "line": 23, "column": 42 }, "end": { "line": 23, "column": 49 }, "identifierName": "options" }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 460, "end": 3556, "loc": { "start": { "line": 23, "column": 51 }, "end": { "line": 96, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 466, "end": 582, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 28, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 466, "end": 581, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 28, "column": 21 } }, "operator": "=", "left": { "type": "Identifier", "start": 466, "end": 473, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 11 }, "identifierName": "options" }, "name": "options" }, "right": { "type": "CallExpression", "start": 476, "end": 581, "loc": { "start": { "line": 24, "column": 14 }, "end": { "line": 28, "column": 21 } }, "callee": { "type": "MemberExpression", "start": 476, "end": 490, "loc": { "start": { "line": 24, "column": 14 }, "end": { "line": 24, "column": 28 } }, "object": { "type": "MemberExpression", "start": 476, "end": 483, "loc": { "start": { "line": 24, "column": 14 }, "end": { "line": 24, "column": 21 } }, "object": { "type": "Identifier", "start": 476, "end": 481, "loc": { "start": { "line": 24, "column": 14 }, "end": { "line": 24, "column": 19 }, "identifierName": "Utils" }, "name": "Utils" }, "property": { "type": "Identifier", "start": 482, "end": 483, "loc": { "start": { "line": 24, "column": 20 }, "end": { "line": 24, "column": 21 }, "identifierName": "_" }, "name": "_" }, "computed": false }, "property": { "type": "Identifier", "start": 484, "end": 490, "loc": { "start": { "line": 24, "column": 22 }, "end": { "line": 24, "column": 28 }, "identifierName": "extend" }, "name": "extend" }, "computed": false }, "arguments": [ { "type": "ObjectExpression", "start": 491, "end": 565, "loc": { "start": { "line": 24, "column": 29 }, "end": { "line": 28, "column": 5 } }, "properties": [ { "type": "ObjectProperty", "start": 499, "end": 515, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 22 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 499, "end": 505, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 12 }, "identifierName": "engine" }, "name": "engine" }, "value": { "type": "StringLiteral", "start": 507, "end": 515, "loc": { "start": { "line": 25, "column": 14 }, "end": { "line": 25, "column": 22 } }, "extra": { "rawValue": "InnoDB", "raw": "'InnoDB'" }, "value": "InnoDB" } }, { "type": "ObjectProperty", "start": 523, "end": 536, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 19 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 523, "end": 530, "loc": { "start": { "line": 26, "column": 6 }, "end": { "line": 26, "column": 13 }, "identifierName": "charset" }, "name": "charset" }, "value": { "type": "NullLiteral", "start": 532, "end": 536, "loc": { "start": { "line": 26, "column": 15 }, "end": { "line": 26, "column": 19 } } } }, { "type": "ObjectProperty", "start": 544, "end": 559, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 21 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 544, "end": 553, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 15 }, "identifierName": "rowFormat" }, "name": "rowFormat" }, "value": { "type": "NullLiteral", "start": 555, "end": 559, "loc": { "start": { "line": 27, "column": 17 }, "end": { "line": 27, "column": 21 } } } } ] }, { "type": "LogicalExpression", "start": 567, "end": 580, "loc": { "start": { "line": 28, "column": 7 }, "end": { "line": 28, "column": 20 } }, "left": { "type": "Identifier", "start": 567, "end": 574, "loc": { "start": { "line": 28, "column": 7 }, "end": { "line": 28, "column": 14 }, "identifierName": "options" }, "name": "options" }, "operator": "||", "right": { "type": "ObjectExpression", "start": 578, "end": 580, "loc": { "start": { "line": 28, "column": 18 }, "end": { "line": 28, "column": 20 } }, "properties": [] } } ] } } }, { "type": "VariableDeclaration", "start": 588, "end": 771, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 187 } }, "declarations": [ { "type": "VariableDeclarator", "start": 594, "end": 770, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 186 } }, "id": { "type": "Identifier", "start": 594, "end": 599, "loc": { "start": { "line": 30, "column": 10 }, "end": { "line": 30, "column": 15 }, "identifierName": "query" }, "name": "query" }, "init": { "type": "StringLiteral", "start": 602, "end": 770, "loc": { "start": { "line": 30, "column": 18 }, "end": { "line": 30, "column": 186 } }, "extra": { "rawValue": "CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>) ENGINE=<%= engine %><%= comment %><%= charset %><%= collation %><%= initialAutoIncrement %><%= rowFormat %>", "raw": "'CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>) ENGINE=<%= engine %><%= comment %><%= charset %><%= collation %><%= initialAutoIncrement %><%= rowFormat %>'" }, "value": "CREATE TABLE IF NOT EXISTS <%= table %> (<%= attributes%>) ENGINE=<%= engine %><%= comment %><%= charset %><%= collation %><%= initialAutoIncrement %><%= rowFormat %>" } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 776, "end": 799, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", "start": 782, "end": 798, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column": 26 } }, "id": { "type": "Identifier", "start": 782, "end": 793, "loc": { "start": { "line": 31, "column": 10 }, "end": { "line": 31, "column": 21 }, "identifierName": "primaryKeys" }, "name": "primaryKeys" }, "init": { "type": "ArrayExpression", "start": 796, "end": 798, "loc": { "start": { "line": 31, "column": 24 }, "end": { "line": 31, "column": 26 } }, "elements": [] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 804, "end": 827, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", "start": 810, "end": 826, "loc": { "start": { "line": 32, "column": 10 }, "end": { "line": 32, "column": 26 } }, "id": { "type": "Identifier", "start": 810, "end": 821, "loc": { "start": { "line": 32, "column": 10 }, "end": { "line": 32, "column": 21 }, "identifierName": "foreignKeys" }, "name": "foreignKeys" }, "init": { "type": "ObjectExpression", "start": 824, "end": 826, "loc": { "start": { "line": 32, "column": 24 }, "end": { "line": 32, "column": 26 } }, "properties": [] } } ], "kind": "const" }, { "type": "VariableDeclara