UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,426 lines (1,425 loc) 217 kB
{ "type": "File", "start": 0, "end": 1087, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 38, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1087, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 38, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 34 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 } }, "local": { "type": "Identifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 }, "identifierName": "config" }, "name": "config" } } ], "source": { "type": "StringLiteral", "start": 19, "end": 33, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 33 } }, "extra": { "rawValue": "../../config", "raw": "'../../config'" }, "value": "../../config" } }, { "type": "ImportDeclaration", "start": 35, "end": 77, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 42 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 44, "end": 56, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 21 } }, "imported": { "type": "Identifier", "start": 44, "end": 56, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 21 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" }, "local": { "type": "Identifier", "start": 44, "end": 56, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 21 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" } } ], "source": { "type": "StringLiteral", "start": 64, "end": 76, "loc": { "start": { "line": 2, "column": 29 }, "end": { "line": 2, "column": 41 } }, "extra": { "rawValue": "../../core", "raw": "'../../core'" }, "value": "../../core" } }, { "type": "ImportDeclaration", "start": 78, "end": 135, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 57 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 87, "end": 105, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 27 } }, "imported": { "type": "Identifier", "start": 87, "end": 105, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 27 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" }, "local": { "type": "Identifier", "start": 87, "end": 105, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 27 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" } } ], "source": { "type": "StringLiteral", "start": 113, "end": 134, "loc": { "start": { "line": 3, "column": 35 }, "end": { "line": 3, "column": 56 } }, "extra": { "rawValue": "../../utils/helpers", "raw": "'../../utils/helpers'" }, "value": "../../utils/helpers" } }, { "type": "ImportDeclaration", "start": 137, "end": 174, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 37 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 144, "end": 153, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 16 } }, "local": { "type": "Identifier", "start": 144, "end": 153, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 16 }, "identifierName": "RunLogger" }, "name": "RunLogger" } } ], "source": { "type": "StringLiteral", "start": 159, "end": 173, "loc": { "start": { "line": 5, "column": 22 }, "end": { "line": 5, "column": 36 } }, "extra": { "rawValue": "./run-logger", "raw": "'./run-logger'" }, "value": "./run-logger" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Run seeders\n * @param {Object} [options={}] Options\n * @param {string[]} [options.selectedSeeders=[]] Selected seeders to run.\n * When empty, run all seeders.\n * @param {boolean} [options.dropDatabase=false] Drop database before running?\n * @return {Promise}\n ", "start": 176, "end": 511, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 14, "column": 3 } } } ] }, { "type": "Identifier", "start": 512, "end": 1065, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 35, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 518, "end": 1064, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 35, "column": 1 } }, "id": { "type": "Identifier", "start": 518, "end": 521, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 9 }, "identifierName": "run" }, "name": "run", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 524, "end": 1064, "loc": { "start": { "line": 15, "column": 12 }, "end": { "line": 35, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": true, "params": [ { "type": "AssignmentPattern", "start": 531, "end": 582, "loc": { "start": { "line": 15, "column": 19 }, "end": { "line": 15, "column": 70 } }, "left": { "type": "ObjectPattern", "start": 531, "end": 577, "loc": { "start": { "line": 15, "column": 19 }, "end": { "line": 15, "column": 65 } }, "properties": [ { "type": "ObjectProperty", "start": 533, "end": 553, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 41 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 533, "end": 548, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 36 }, "identifierName": "selectedSeeders" }, "name": "selectedSeeders" }, "value": { "type": "AssignmentPattern", "start": 533, "end": 553, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 41 } }, "left": { "type": "Identifier", "start": 533, "end": 548, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 36 }, "identifierName": "selectedSeeders" }, "name": "selectedSeeders" }, "right": { "type": "ArrayExpression", "start": 551, "end": 553, "loc": { "start": { "line": 15, "column": 39 }, "end": { "line": 15, "column": 41 } }, "elements": [] } }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 555, "end": 575, "loc": { "start": { "line": 15, "column": 43 }, "end": { "line": 15, "column": 63 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 555, "end": 567, "loc": { "start": { "line": 15, "column": 43 }, "end": { "line": 15, "column": 55 }, "identifierName": "dropDatabase" }, "name": "dropDatabase" }, "value": { "type": "AssignmentPattern", "start": 555, "end": 575, "loc": { "start": { "line": 15, "column": 43 }, "end": { "line": 15, "column": 63 } }, "left": { "type": "Identifier", "start": 555, "end": 567, "loc": { "start": { "line": 15, "column": 43 }, "end": { "line": 15, "column": 55 }, "identifierName": "dropDatabase" }, "name": "dropDatabase" }, "right": { "type": "BooleanLiteral", "start": 570, "end": 575, "loc": { "start": { "line": 15, "column": 58 }, "end": { "line": 15, "column": 63 } }, "value": false } }, "extra": { "shorthand": true } } ] }, "right": { "type": "ObjectExpression", "start": 580, "end": 582, "loc": { "start": { "line": 15, "column": 68 }, "end": { "line": 15, "column": 70 } }, "properties": [] } } ], "body": { "type": "BlockStatement", "start": 587, "end": 1064, "loc": { "start": { "line": 15, "column": 75 }, "end": { "line": 35, "column": 1 } }, "body": [ { "type": "ExpressionStatement", "start": 591, "end": 612, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 23 } }, "expression": { "type": "CallExpression", "start": 591, "end": 611, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 22 } }, "callee": { "type": "Identifier", "start": 591, "end": 609, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 20 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" }, "arguments": [] }, "trailingComments": [ { "type": "CommentLine", "value": " get relevant user-config", "start": 616, "end": 643, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 29 } } } ] }, { "type": "VariableDeclaration", "start": 646, "end": 711, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 19, "column": 67 } }, "declarations": [ { "type": "VariableDeclarator", "start": 652, "end": 710, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 66 } }, "id": { "type": "ObjectPattern", "start": 652, "end": 684, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 40 } }, "properties": [ { "type": "ObjectProperty", "start": 654, "end": 661, "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 17 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 654, "end": 661, "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 17 }, "identifierName": "connect" }, "name": "connect", "leadingComments": null }, "value": { "type": "Identifier", "start": 654, "end": 661, "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 17 }, "identifierName": "connect" }, "name": "connect" }, "leadingComments": null, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 663, "end": 669, "loc": { "start": { "line": 19, "column": 19 }, "end": { "line": 19, "column": 25 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 663, "end": 669, "loc": { "start": { "line": 19, "column": 19 }, "end": { "line": 19, "column": 25 }, "identifierName": "dropdb" }, "name": "dropdb" }, "value": { "type": "Identifier", "start": 663, "end": 669, "loc": { "start": { "line": 19, "column": 19 }, "end": { "line": 19, "column": 25 }, "identifierName": "dropdb" }, "name": "dropdb" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 671, "end": 682, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 38 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 671, "end": 682, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 38 }, "identifierName": "seedersList" }, "name": "seedersList" }, "value": { "type": "Identifier", "start": 671, "end": 682, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 38 }, "identifierName": "seedersList" }, "name": "seedersList" }, "extra": { "shorthand": true } } ], "leadingComments": null }, "init": { "type": "CallExpression", "start": 687, "end": 710, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 19, "column": 66 } }, "callee": { "type": "MemberExpression", "start": 687, "end": 708, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 19, "column": 64 } }, "object": { "type": "Identifier", "start": 687, "end": 693, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 19, "column": 49 }, "identifierName": "config" }, "name": "config" }, "property": { "type": "Identifier", "start": 694, "end": 708, "loc": { "start": { "line": 19, "column": 50 }, "end": { "line": 19, "column": 64 }, "identifierName": "loadUserConfig" }, "name": "loadUserConfig" }, "computed": false }, "arguments": [] }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentLine", "value": " get relevant user-config", "start": 616, "end": 643, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 29 } } } ], "trailingComments": [ { "type": "CommentLine", "value": " create logger", "start": 715, "end": 731, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 21, "column": 18 } } } ] }, { "type": "VariableDeclaration", "start": 734, "end": 765, "loc": { "start": { "line": 22, "column": 2 }, "end": { "line": 22, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 740, "end": 764, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 32 } }, "id": { "type": "Identifier", "start": 740, "end": 746, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 14 }, "identifierName": "logger" }, "name": "logger", "leadingComments": null }, "init": { "type": "NewExpression", "start": 749, "end": 764, "loc": { "start": { "line": 22, "column": 17 }, "end": { "line": 22, "column": 32 } }, "callee": { "type": "Identifier", "start": 753, "end": 762, "loc": { "start": { "line": 22, "column": 21 }, "end": { "line": 22, "column": 30 }, "identifierName": "RunLogger" }, "name": "RunLogger" }, "arguments": [] }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentLine", "value": " create logger", "start": 715, "end": 731, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 21, "column": 18 } } } ], "trailingComments": [ { "type": "CommentLine", "value": " create runner", "start": 769, "end": 785, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 24, "column": 18 } } } ] }, { "type": "VariableDeclaration", "start": 788, "end": 854, "loc": { "start": { "line": 25, "column": 2 }, "end": { "line": 25, "column": 68 } }, "declarations": [ { "type": "VariableDeclarator", "start": 794, "end": 853, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 67 } }, "id": { "type": "Identifier", "start": 794, "end": 800, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 14 }, "identifierName": "runner" }, "name": "runner", "leadingComments": null }, "init": { "type": "NewExpression", "start": 803, "end": 853, "loc": { "start": { "line": 25, "column": 17 }, "end": { "line": 25, "column": 67 } }, "callee": { "type": "Identifier", "start": 807, "end": 819, "loc": { "start": { "line": 25, "column": 21 }, "end": { "line": 25, "column": 33 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" }, "arguments": [ { "type": "ObjectExpression", "start": 820, "end": 852, "loc": { "start": { "line": 25, "column": 34 }, "end": { "line": 25, "column": 66 } }, "properties": [ { "type": "ObjectProperty", "start": 822, "end": 829, "loc": { "start": { "line": 25, "column": 36 }, "end": { "line": 25, "column": 43 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 822, "end": 829, "loc": { "start": { "line": 25, "column": 36 }, "end": { "line": 25, "column": 43 }, "identifierName": "connect" }, "name": "connect" }, "value": { "type": "Identifier", "start": 822, "end": 829, "loc": { "start": { "line": 25, "column": 36 }, "end": { "line": 25, "column": 43 }, "identifierName": "connect" }, "name": "connect" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 831, "end": 837, "loc": { "start": { "line": 25, "column": 45 }, "end": { "line": 25, "column": 51 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 831, "end": 837, "loc": { "start": { "line": 25, "column": 45 }, "end": { "line": 25, "column": 51 }, "identifierName": "dropdb" }, "name": "dropdb" }, "value": { "type": "Identifier", "start": 831, "end": 837, "loc": { "start": { "line": 25, "column": 45 }, "end": { "line": 25, "column": 51 }, "identifierName": "dropdb" }, "name": "dropdb" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 839, "end": 850, "loc": { "start": { "line": 25, "column": 53 }, "end": { "line": 25, "column": 64 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 839, "end": 850, "loc": { "start": { "line": 25, "column": 53 }, "end": { "line": 25, "column": 64 }, "identifierName": "seedersList" }, "name": "seedersList" }, "value": { "type": "Identifier", "start": 839, "end": 850, "loc": { "start": { "line": 25, "column": 53 }, "end": { "line": 25, "column": 64 }, "identifierName": "seedersList" }, "name": "seedersList" }, "extra": { "shorthand": true