UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,519 lines (1,518 loc) 838 kB
{ "type": "File", "start": 0, "end": 4690, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 183, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 4690, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 183, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 31, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 31 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 9, "end": 16, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 } }, "imported": { "type": "Identifier", "start": 9, "end": 16, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 }, "identifierName": "Subject" }, "name": "Subject" }, "local": { "type": "Identifier", "start": 9, "end": 16, "loc": { "start": { "line": 1, "column": 9 }, "end": { "line": 1, "column": 16 }, "identifierName": "Subject" }, "name": "Subject" } } ], "source": { "type": "StringLiteral", "start": 24, "end": 30, "loc": { "start": { "line": 1, "column": 24 }, "end": { "line": 1, "column": 30 } }, "extra": { "rawValue": "rxjs", "raw": "'rxjs'" }, "value": "rxjs" } }, { "type": "ImportDeclaration", "start": 33, "end": 120, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 6, "column": 26 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 44, "end": 69, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 } }, "imported": { "type": "Identifier", "start": 44, "end": 69, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 }, "identifierName": "getObjectWithSelectedKeys" }, "name": "getObjectWithSelectedKeys" }, "local": { "type": "Identifier", "start": 44, "end": 69, "loc": { "start": { "line": 4, "column": 2 }, "end": { "line": 4, "column": 27 }, "identifierName": "getObjectWithSelectedKeys" }, "name": "getObjectWithSelectedKeys" } }, { "type": "ImportSpecifier", "start": 73, "end": 92, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 21 } }, "imported": { "type": "Identifier", "start": 73, "end": 92, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 21 }, "identifierName": "normalizeSeederName" }, "name": "normalizeSeederName" }, "local": { "type": "Identifier", "start": 73, "end": 92, "loc": { "start": { "line": 5, "column": 2 }, "end": { "line": 5, "column": 21 }, "identifierName": "normalizeSeederName" }, "name": "normalizeSeederName" } } ], "source": { "type": "StringLiteral", "start": 101, "end": 119, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 25 } }, "extra": { "rawValue": "../utils/helpers", "raw": "'../utils/helpers'" }, "value": "../utils/helpers" } }, { "type": "ImportDeclaration", "start": 121, "end": 176, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 55 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 128, "end": 145, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 24 } }, "local": { "type": "Identifier", "start": 128, "end": 145, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 24 }, "identifierName": "MdSeedRunnerError" }, "name": "MdSeedRunnerError" } } ], "source": { "type": "StringLiteral", "start": 151, "end": 175, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 54 } }, "extra": { "rawValue": "./md-seed-runner-error", "raw": "'./md-seed-runner-error'" }, "value": "./md-seed-runner-error" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * mongoose-data-seed runner\n ", "start": 178, "end": 214, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 11, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 215, "end": 4689, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 182, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 230, "end": 4689, "loc": { "start": { "line": 12, "column": 15 }, "end": { "line": 182, "column": 1 } }, "id": { "type": "Identifier", "start": 236, "end": 248, "loc": { "start": { "line": 12, "column": 21 }, "end": { "line": 12, "column": 33 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 249, "end": 4689, "loc": { "start": { "line": 12, "column": 34 }, "end": { "line": 182, "column": 1 } }, "body": [ { "type": "ClassProperty", "start": 515, "end": 1115, "loc": { "start": { "line": 20, "column": 2 }, "end": { "line": 35, "column": 4 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 522, "end": 532, "loc": { "start": { "line": 20, "column": 9 }, "end": { "line": 20, "column": 19 }, "identifierName": "operations" }, "name": "operations" }, "value": { "type": "ObjectExpression", "start": 535, "end": 1114, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 35, "column": 3 } }, "properties": [ { "type": "ObjectProperty", "start": 541, "end": 555, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 541, "end": 546, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 9 }, "identifierName": "START" }, "name": "START" }, "value": { "type": "StringLiteral", "start": 548, "end": 555, "loc": { "start": { "line": 21, "column": 11 }, "end": { "line": 21, "column": 18 } }, "extra": { "rawValue": "START", "raw": "'START'" }, "value": "START" } }, { "type": "ObjectProperty", "start": 561, "end": 579, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 22 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 561, "end": 568, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 11 }, "identifierName": "SUCCESS" }, "name": "SUCCESS" }, "value": { "type": "StringLiteral", "start": 570, "end": 579, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 22 } }, "extra": { "rawValue": "SUCCESS", "raw": "'SUCCESS'" }, "value": "SUCCESS" } }, { "type": "ObjectProperty", "start": 585, "end": 599, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 585, "end": 590, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 9 }, "identifierName": "ERROR" }, "name": "ERROR" }, "value": { "type": "StringLiteral", "start": 592, "end": 599, "loc": { "start": { "line": 23, "column": 11 }, "end": { "line": 23, "column": 18 } }, "extra": { "rawValue": "ERROR", "raw": "'ERROR'" }, "value": "ERROR" } }, { "type": "ObjectProperty", "start": 605, "end": 653, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 52 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 605, "end": 627, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 26 }, "identifierName": "MONGOOSE_CONNECT_START" }, "name": "MONGOOSE_CONNECT_START" }, "value": { "type": "StringLiteral", "start": 629, "end": 653, "loc": { "start": { "line": 24, "column": 28 }, "end": { "line": 24, "column": 52 } }, "extra": { "rawValue": "MONGOOSE_CONNECT_START", "raw": "'MONGOOSE_CONNECT_START'" }, "value": "MONGOOSE_CONNECT_START" } }, { "type": "ObjectProperty", "start": 659, "end": 711, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 56 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 659, "end": 683, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 28 }, "identifierName": "MONGOOSE_CONNECT_SUCCESS" }, "name": "MONGOOSE_CONNECT_SUCCESS" }, "value": { "type": "StringLiteral", "start": 685, "end": 711, "loc": { "start": { "line": 25, "column": 30 }, "end": { "line": 25, "column": 56 } }, "extra": { "rawValue": "MONGOOSE_CONNECT_SUCCESS", "raw": "'MONGOOSE_CONNECT_SUCCESS'" }, "value": "MONGOOSE_CONNECT_SUCCESS" } }, { "type": "ObjectProperty", "start": 717, "end": 765, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 52 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 717, "end": 739, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 26 }, "identifierName": "MONGOOSE_CONNECT_ERROR" }, "name": "MONGOOSE_CONNECT_ERROR" }, "value": { "type": "StringLiteral", "start": 741, "end": 765, "loc": { "start": { "line": 26, "column": 28 }, "end": { "line": 26, "column": 52 } }, "extra": { "rawValue": "MONGOOSE_CONNECT_ERROR", "raw": "'MONGOOSE_CONNECT_ERROR'" }, "value": "MONGOOSE_CONNECT_ERROR" } }, { "type": "ObjectProperty", "start": 771, "end": 813, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 46 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 771, "end": 790, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 27, "column": 23 }, "identifierName": "MONGOOSE_DROP_START" }, "name": "MONGOOSE_DROP_START" }, "value": { "type": "StringLiteral", "start": 792, "end": 813, "loc": { "start": { "line": 27, "column": 25 }, "end": { "line": 27, "column": 46 } }, "extra": { "rawValue": "MONGOOSE_DROP_START", "raw": "'MONGOOSE_DROP_START'" }, "value": "MONGOOSE_DROP_START" } }, { "type": "ObjectProperty", "start": 819, "end": 865, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 50 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 819, "end": 840, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 25 }, "identifierName": "MONGOOSE_DROP_SUCCESS" }, "name": "MONGOOSE_DROP_SUCCESS" }, "value": { "type": "StringLiteral", "start": 842, "end": 865, "loc": { "start": { "line": 28, "column": 27 }, "end": { "line": 28, "column": 50 } }, "extra": { "rawValue": "MONGOOSE_DROP_SUCCESS", "raw": "'MONGOOSE_DROP_SUCCESS'" }, "value": "MONGOOSE_DROP_SUCCESS" } }, { "type": "ObjectProperty", "start": 871, "end": 913, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 46 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 871, "end": 890, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 23 }, "identifierName": "MONGOOSE_DROP_ERROR" }, "name": "MONGOOSE_DROP_ERROR" }, "value": { "type": "StringLiteral", "start": 892, "end": 913, "loc": { "start": { "line": 29, "column": 25 }, "end": { "line": 29, "column": 46 } }, "extra": { "rawValue": "MONGOOSE_DROP_ERROR", "raw": "'MONGOOSE_DROP_ERROR'" }, "value": "MONGOOSE_DROP_ERROR" } }, { "type": "ObjectProperty", "start": 919, "end": 957, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 42 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 919, "end": 936, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 21 }, "identifierName": "ALL_SEEDERS_START" }, "name": "ALL_SEEDERS_START" }, "value": { "type": "StringLiteral", "start": 938, "end": 957, "loc": { "start": { "line": 30, "column": 23 }, "end": { "line": 30, "column": 42 } }, "extra": { "rawValue": "ALL_SEEDERS_START", "raw": "'ALL_SEEDERS_START'" }, "value": "ALL_SEEDERS_START" } }, { "type": "ObjectProperty", "start": 963, "end": 1003, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 44 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 963, "end": 981, "loc": { "start": { "line": 31, "column": 4 }, "end": { "line": 31, "column": 22 }, "identifierName": "ALL_SEEDERS_FINISH" }, "name": "ALL_SEEDERS_FINISH" }, "value": { "type": "StringLiteral", "start": 983, "end": 1003, "loc": { "start": { "line": 31, "column": 24 }, "end": { "line": 31, "column": 44 } }, "extra": { "rawValue": "ALL_SEEDERS_FINISH", "raw": "'ALL_SEEDERS_FINISH'" }, "value": "ALL_SEEDERS_FINISH" } }, { "type": "ObjectProperty", "start": 1009, "end": 1037, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 32 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1009, "end": 1021, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 16 }, "identifierName": "SEEDER_START" }, "name": "SEEDER_START" }, "value": { "type": "StringLiteral", "start": 1023, "end": 1037, "loc": { "start": { "line": 32, "column": 18 }, "end": { "line": 32, "column": 32 } }, "extra": { "rawValue": "SEEDER_START", "raw": "'SEEDER_START'" }, "value": "SEEDER_START" } }, { "type": "ObjectProperty", "start": 1043, "end": 1075, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 33, "column": 36 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1043, "end": 1057, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 33, "column": 18 }, "identifierName": "SEEDER_SUCCESS" }, "name": "SEEDER_SUCCESS" }, "value": { "type": "StringLiteral", "start": 1059, "end": 1075, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 36 } }, "extra": { "rawValue": "SEEDER_SUCCESS", "raw": "'SEEDER_SUCCESS'" }, "value": "SEEDER_SUCCESS" } }, { "type": "ObjectProperty", "start": 1081, "end": 1109, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 32 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1081, "end": 1093, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 16 }, "identifierName": "SEEDER_ERROR" }, "name": "SEEDER_ERROR" }, "value": { "type": "StringLiteral", "start": 1095, "end": 1109, "loc": { "start": { "line": 34, "column": 18 }, "end": { "line": 34, "column": 32 } }, "extra": { "rawValue": "SEEDER_ERROR", "raw": "'SEEDER_ERROR'" }, "value": "SEEDER_ERROR" } } ] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * MdSeedRunner operations constants\n * @type {Object}\n * @property {string} START MdSeedRunner starts.\n * @property {string} SUCCESS MdSeedRunner succeed.\n * @property {string} ERROR MdSeedRunner finished with an error.\n ", "start": 253, "end": 512, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 19, "column": 5 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Creates MdSeedRunner\n * @param {Function<Promise>} connect Connect to mongodb implementation\n * @param {Function<Promise>} dropdb Drop/Clear the database implementation\n * @param {Map<string, Function>} seedersList key=Seeder name | value=Seeder implementation\n ", "start": 1119, "end": 1417, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 42, "column": 5 } } } ] }, { "type": "ClassMethod", "start": 1420, "end": 1596, "loc": { "start": { "line": 43, "column": 2 }, "end": { "line": 48, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1420, "end": 1431, "loc": { "start": { "line": 43, "column": 2 }, "end": { "line": 43, "column": 13 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "ObjectPattern", "start": 1432, "end": 1464, "loc": { "start": { "line": 43, "column": 14 }, "end": { "line": 43, "column": 46 } }, "properties": [ { "type": "ObjectProperty", "start": 1434, "end": 1441, "loc": { "start": { "line": 43, "column": 16 }, "end": { "line": 43, "column": 23 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 1434, "end": 1441, "loc": { "start": { "line": 43, "column": 16 }, "end": { "line": 43, "column": 23 }, "identifierName": "connect" }, "name": "connect" }, "value": { "type": "Identifier", "start": 1434, "end": 1441, "loc": { "start": { "line": 43, "column": 16 }, "end": { "line": 43, "column": 23 }, "identifierName": "connect" }, "name": "connect" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 1443, "end": 1449, "loc": { "start": { "line": 43, "column": 25 }, "end": { "line": 43, "column": 31 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 1443, "end": 1449, "loc": { "start": { "line": 43, "column": 25 }, "end": { "line": 43, "column": 31 }, "identifierName": "dropdb" }, "name": "dropdb" }, "value": { "type": "Identifier", "start": 1443, "end": 1449, "loc": { "start": { "line": 43, "column": 25 }, "end": { "line": 43, "column": 31 }, "identifierName": "dropdb" }, "name": "dropdb" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 1451, "end": 1462, "loc": { "start": { "line": 43, "column": 33 }, "end": { "line": 43, "column": 44 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 1451, "end": 1462, "loc": { "start": { "line": 43, "column": 33 }, "end": { "line": 43, "column": 44 }, "identifierName": "seedersList" }, "name": "seedersList" }, "value": { "type": "Identifier", "start": 1451, "end": 1462, "loc": { "start": { "line": 43, "column": 33 }, "end": { "line": 43, "column": 44 }, "identifierName": "seedersList" }, "name": "seedersList" }, "extra": { "shorthand": true } } ] } ], "body": { "type": "BlockStatement", "start": 1466, "end": 1596, "loc": { "start": { "line": 43, "column": 48 }, "end": { "line": 48, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 1472, "end": 1495, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 44, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 1472, "end": 1494, "loc": { "start": { "line": 44, "column": 4 },