UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,785 lines (1,784 loc) 77.8 kB
{ "type": "File", "start": 0, "end": 567, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 27, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 567, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 27, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 25, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 25 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 7, "end": 24, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 24 } }, "extra": { "rawValue": "@babel/register", "raw": "'@babel/register'" }, "value": "@babel/register" } }, { "type": "ImportDeclaration", "start": 26, "end": 50, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 24 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 33, "end": 49, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 23 } }, "extra": { "rawValue": "core-js/stable", "raw": "'core-js/stable'" }, "value": "core-js/stable" } }, { "type": "ImportDeclaration", "start": 51, "end": 88, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 37 } }, "specifiers": [], "source": { "type": "StringLiteral", "start": 58, "end": 87, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 36 } }, "extra": { "rawValue": "regenerator-runtime/runtime", "raw": "'regenerator-runtime/runtime'" }, "value": "regenerator-runtime/runtime" } }, { "type": "ImportDeclaration", "start": 90, "end": 169, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 79 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 99, "end": 109, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 19 } }, "imported": { "type": "Identifier", "start": 99, "end": 109, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 19 }, "identifierName": "runCommand" }, "name": "runCommand" }, "local": { "type": "Identifier", "start": 99, "end": 109, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 19 }, "identifierName": "runCommand" }, "name": "runCommand" } }, { "type": "ImportSpecifier", "start": 111, "end": 135, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 45 } }, "imported": { "type": "Identifier", "start": 111, "end": 135, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 45 }, "identifierName": "getCommandAndArgvFromCli" }, "name": "getCommandAndArgvFromCli" }, "local": { "type": "Identifier", "start": 111, "end": 135, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 45 }, "identifierName": "getCommandAndArgvFromCli" }, "name": "getCommandAndArgvFromCli" } } ], "source": { "type": "StringLiteral", "start": 143, "end": 168, "loc": { "start": { "line": 5, "column": 53 }, "end": { "line": 5, "column": 78 } }, "extra": { "rawValue": "../lib/commands/helpers", "raw": "'../lib/commands/helpers'" }, "value": "../lib/commands/helpers" } }, { "type": "ImportDeclaration", "start": 170, "end": 214, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 44 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 179, "end": 183, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 13 } }, "imported": { "type": "Identifier", "start": 179, "end": 183, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 13 }, "identifierName": "exit" }, "name": "exit" }, "local": { "type": "Identifier", "start": 179, "end": 183, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 13 }, "identifierName": "exit" }, "name": "exit" } } ], "source": { "type": "StringLiteral", "start": 191, "end": 213, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6, "column": 43 } }, "extra": { "rawValue": "../lib/utils/helpers", "raw": "'../lib/utils/helpers'" }, "value": "../lib/utils/helpers" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Main entry point, run md-seed cli\n * @return {Promise}\n ", "start": 216, "end": 281, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 11, "column": 3 } } } ] }, { "type": "VariableDeclaration", "start": 282, "end": 558, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 24, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 288, "end": 557, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 24, "column": 1 } }, "id": { "type": "Identifier", "start": 288, "end": 291, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 9 }, "identifierName": "run" }, "name": "run", "leadingComments": null }, "init": { "type": "ArrowFunctionExpression", "start": 294, "end": 557, "loc": { "start": { "line": 12, "column": 12 }, "end": { "line": 24, "column": 1 } }, "id": { "type": "Identifier", "start": 288, "end": 291, "loc": { "start": { "line": 12, "column": 6 }, "end": { "line": 12, "column": 9 }, "identifierName": "run" }, "name": "run", "leadingComments": null }, "generator": false, "expression": false, "async": true, "params": [], "body": { "type": "BlockStatement", "start": 306, "end": 557, "loc": { "start": { "line": 12, "column": 24 }, "end": { "line": 24, "column": 1 } }, "body": [ { "type": "TryStatement", "start": 310, "end": 555, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 23, "column": 3 } }, "block": { "type": "BlockStatement", "start": 314, "end": 518, "loc": { "start": { "line": 13, "column": 6 }, "end": { "line": 21, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 383, "end": 436, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 57 } }, "declarations": [ { "type": "VariableDeclarator", "start": 389, "end": 435, "loc": { "start": { "line": 15, "column": 10 }, "end": { "line": 15, "column": 56 } }, "id": { "type": "ObjectPattern", "start": 389, "end": 406, "loc": { "start": { "line": 15, "column": 10 }, "end": { "line": 15, "column": 27 } }, "properties": [ { "type": "ObjectProperty", "start": 391, "end": 398, "loc": { "start": { "line": 15, "column": 12 }, "end": { "line": 15, "column": 19 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 391, "end": 398, "loc": { "start": { "line": 15, "column": 12 }, "end": { "line": 15, "column": 19 }, "identifierName": "command" }, "name": "command", "leadingComments": null }, "value": { "type": "Identifier", "start": 391, "end": 398, "loc": { "start": { "line": 15, "column": 12 }, "end": { "line": 15, "column": 19 }, "identifierName": "command" }, "name": "command" }, "leadingComments": null, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 400, "end": 404, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 25 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 400, "end": 404, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 25 }, "identifierName": "argv" }, "name": "argv" }, "value": { "type": "Identifier", "start": 400, "end": 404, "loc": { "start": { "line": 15, "column": 21 }, "end": { "line": 15, "column": 25 }, "identifierName": "argv" }, "name": "argv" }, "extra": { "shorthand": true } } ], "leadingComments": null }, "init": { "type": "CallExpression", "start": 409, "end": 435, "loc": { "start": { "line": 15, "column": 30 }, "end": { "line": 15, "column": 56 } }, "callee": { "type": "Identifier", "start": 409, "end": 433, "loc": { "start": { "line": 15, "column": 30 }, "end": { "line": 15, "column": 54 }, "identifierName": "getCommandAndArgvFromCli" }, "name": "getCommandAndArgvFromCli" }, "arguments": [] }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentLine", "value": " recive the command and the arguments input from the cli", "start": 320, "end": 378, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 62 } } } ], "trailingComments": [ { "type": "CommentLine", "value": " run the cli command", "start": 442, "end": 464, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 26 } } } ] }, { "type": "ExpressionStatement", "start": 469, "end": 501, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 36 } }, "expression": { "type": "AwaitExpression", "start": 469, "end": 500, "loc": { "start": { "line": 18, "column": 4 }, "end": { "line": 18, "column": 35 } }, "argument": { "type": "CallExpression", "start": 475, "end": 500, "loc": { "start": { "line": 18, "column": 10 }, "end": { "line": 18, "column": 35 } }, "callee": { "type": "Identifier", "start": 475, "end": 485, "loc": { "start": { "line": 18, "column": 10 }, "end": { "line": 18, "column": 20 }, "identifierName": "runCommand" }, "name": "runCommand" }, "arguments": [ { "type": "Identifier", "start": 486, "end": 493, "loc": { "start": { "line": 18, "column": 21 }, "end": { "line": 18, "column": 28 }, "identifierName": "command" }, "name": "command" }, { "type": "Identifier", "start": 495, "end": 499, "loc": { "start": { "line": 18, "column": 30 }, "end": { "line": 18, "column": 34 }, "identifierName": "argv" }, "name": "argv" } ] }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": " run the cli command", "start": 442, "end": 464, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 26 } } } ] }, { "type": "ExpressionStatement", "start": 507, "end": 514, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 11 } }, "expression": { "type": "CallExpression", "start": 507, "end": 513, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 10 } }, "callee": { "type": "Identifier", "start": 507, "end": 511, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 8 }, "identifierName": "exit" }, "name": "exit" }, "arguments": [] } } ], "directives": [] }, "handler": { "type": "CatchClause", "start": 519, "end": 555, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 23, "column": 3 } }, "param": { "type": "Identifier", "start": 526, "end": 531, "loc": { "start": { "line": 21, "column": 11 }, "end": { "line": 21, "column": 16 }, "identifierName": "error" }, "name": "error" }, "body": { "type": "BlockStatement", "start": 533, "end": 555, "loc": { "start": { "line": 21, "column": 18 }, "end": { "line": 23, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 539, "end": 551, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 16 } }, "expression": { "type": "CallExpression", "start": 539, "end": 550, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 15 } }, "callee": { "type": "Identifier", "start": 539, "end": 543, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 8 }, "identifierName": "exit" }, "name": "exit" }, "arguments": [ { "type": "Identifier", "start": 544, "end": 549, "loc": { "start": { "line": 22, "column": 9 }, "end": { "line": 22, "column": 14 }, "identifierName": "error" }, "name": "error" } ] } } ], "directives": [] } }, "guardedHandlers": [], "finalizer": null } ], "directives": [] } }, "leadingComments": null } ], "kind": "const", "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Main entry point, run md-seed cli\n * @return {Promise}\n ", "start": 216, "end": 281, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 11, "column": 3 } } } ] }, { "type": "ExpressionStatement", "start": 560, "end": 566, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 6 } }, "expression": { "type": "CallExpression", "start": 560, "end": 565, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 5 } }, "callee": { "type": "Identifier", "start": 560, "end": 563, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 3 }, "identifierName": "run" }, "name": "run" }, "arguments": [] } } ], "directives": [] }, "comments": [ { "type": "CommentBlock", "value": "*\n * Main entry point, run md-seed cli\n * @return {Promise}\n ", "start": 216, "end": 281, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 11, "column": 3 } } }, { "type": "CommentLine", "value": " recive the command and the arguments input from the cli", "start": 320, "end": 378, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 62 } } }, { "type": "CommentLine", "value": " run the cli command", "start": 442, "end": 464, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 26 } } } ], "tokens": [ { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 0, "end": 6, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 6 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "@babel/register", "start": 7, "end": 24, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 24 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 24, "end": 25, "loc": { "start": { "line": 1, "column": 24 }, "end": { "line": 1, "column": 25 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 26, "end": 32, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 6 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "core-js/stable", "start": 33, "end": 49, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 23 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 49, "end": 50, "loc": { "start": { "line": 2, "column": 23 }, "end": { "line": 2, "column": 24 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 51, "end": 57, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 6 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "regenerator-runtime/runtime", "start": 58, "end": 87, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 36 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 87, "end": 88, "loc": { "start": { "line": 3, "column": 36 }, "end": { "line": 3, "column": 37 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 90, "end": 96, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 6 } } }, { "type": { "label": "{", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 97, "end": 98, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 8 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "runCommand", "start": 99, "end": 109, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 19 } } }, { "type": { "label": ",", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 109, "end": 110, "loc": { "start": { "line": 5, "column": 19 }, "end": { "line": 5, "column": 20 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "getCommandAndArgvFromCli", "start": 111, "end": 135, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 45 } } }, { "type": { "label": "}", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 136, "end": 137, "loc": { "start": { "line": 5, "column": 46 }, "end": { "line": 5, "column": 47 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "from", "start": 138, "end": 142, "loc": { "start": { "line": 5, "column": 48 }, "end": { "line": 5, "column": 52 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "../lib/commands/helpers", "start": 143, "end": 168, "loc": { "start": { "line": 5, "column": 53 }, "end": { "line": 5, "column": 78 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 168, "end": 169, "loc": { "start": { "line": 5, "column": 78 }, "end": { "line": 5, "column": 79 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 170, "end": 176, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 6 } } }, { "type": { "label": "{", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 177, "end": 178, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 8 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "exit", "start": 179, "end": 183, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 13 } } }, { "type": { "label": "}", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 184, "end": 185, "loc": { "start": { "line": 6, "column": 14 }, "end": { "line": 6, "column": 15 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "from", "start": 186, "end": 190, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 20 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "../lib/utils/helpers", "start": 191, "end": 213, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6,