mongoose-data-seed
Version:
Seed mongodb with data using mongoose models
1,637 lines • 156 kB
JSON
{
"type": "File",
"start": 0,
"end": 1376,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 60,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1376,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 60,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 56,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 56
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 26
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "commandLineCommands"
},
"name": "commandLineCommands"
}
}
],
"source": {
"type": "StringLiteral",
"start": 32,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 55
}
},
"extra": {
"rawValue": "command-line-commands",
"raw": "'command-line-commands'"
},
"value": "command-line-commands"
}
},
{
"type": "ImportDeclaration",
"start": 57,
"end": 156,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 7,
"column": 21
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 68,
"end": 79,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"imported": {
"type": "Identifier",
"start": 68,
"end": 79,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "commandsMap"
},
"name": "commandsMap"
},
"local": {
"type": "Identifier",
"start": 68,
"end": 79,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "commandsMap"
},
"name": "commandsMap"
}
},
{
"type": "ImportSpecifier",
"start": 83,
"end": 90,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 9
}
},
"imported": {
"type": "Identifier",
"start": 83,
"end": 90,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 9
},
"identifierName": "aliases"
},
"name": "aliases"
},
"local": {
"type": "Identifier",
"start": 83,
"end": 90,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 9
},
"identifierName": "aliases"
},
"name": "aliases"
}
},
{
"type": "ImportSpecifier",
"start": 94,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 16
}
},
"imported": {
"type": "Identifier",
"start": 94,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 16
},
"identifierName": "defaultCommand"
},
"name": "defaultCommand"
},
"local": {
"type": "Identifier",
"start": 94,
"end": 108,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 16
},
"identifierName": "defaultCommand"
},
"name": "defaultCommand"
}
},
{
"type": "ImportSpecifier",
"start": 112,
"end": 133,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 23
}
},
"imported": {
"type": "Identifier",
"start": 112,
"end": 133,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 23
},
"identifierName": "availableCommandsList"
},
"name": "availableCommandsList"
},
"local": {
"type": "Identifier",
"start": 112,
"end": 133,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 23
},
"identifierName": "availableCommandsList"
},
"name": "availableCommandsList"
}
}
],
"source": {
"type": "StringLiteral",
"start": 142,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 7
},
"end": {
"line": 7,
"column": 20
}
},
"extra": {
"rawValue": "./constants",
"raw": "'./constants'"
},
"value": "./constants"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Whether a given command is an alias\n * @param {string} command\n * @return {Boolean}\n ",
"start": 158,
"end": 254,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 13,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 255,
"end": 328,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 14,
"column": 73
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 262,
"end": 328,
"loc": {
"start": {
"line": 14,
"column": 7
},
"end": {
"line": 14,
"column": 73
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 268,
"end": 327,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 72
}
},
"id": {
"type": "Identifier",
"start": 268,
"end": 275,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 20
},
"identifierName": "isAlias"
},
"name": "isAlias",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 278,
"end": 327,
"loc": {
"start": {
"line": 14,
"column": 23
},
"end": {
"line": 14,
"column": 72
}
},
"id": {
"type": "Identifier",
"start": 268,
"end": 275,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 20
},
"identifierName": "isAlias"
},
"name": "isAlias",
"leadingComments": null
},
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 278,
"end": 285,
"loc": {
"start": {
"line": 14,
"column": 23
},
"end": {
"line": 14,
"column": 30
},
"identifierName": "command"
},
"name": "command"
}
],
"body": {
"type": "CallExpression",
"start": 289,
"end": 327,
"loc": {
"start": {
"line": 14,
"column": 34
},
"end": {
"line": 14,
"column": 72
}
},
"callee": {
"type": "MemberExpression",
"start": 289,
"end": 318,
"loc": {
"start": {
"line": 14,
"column": 34
},
"end": {
"line": 14,
"column": 63
}
},
"object": {
"type": "CallExpression",
"start": 289,
"end": 309,
"loc": {
"start": {
"line": 14,
"column": 34
},
"end": {
"line": 14,
"column": 54
}
},
"callee": {
"type": "MemberExpression",
"start": 289,
"end": 300,
"loc": {
"start": {
"line": 14,
"column": 34
},
"end": {
"line": 14,
"column": 45
}
},
"object": {
"type": "Identifier",
"start": 289,
"end": 295,
"loc": {
"start": {
"line": 14,
"column": 34
},
"end": {
"line": 14,
"column": 40
},
"identifierName": "Object"
},
"name": "Object"
},
"property": {
"type": "Identifier",
"start": 296,
"end": 300,
"loc": {
"start": {
"line": 14,
"column": 41
},
"end": {
"line": 14,
"column": 45
},
"identifierName": "keys"
},
"name": "keys"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 301,
"end": 308,
"loc": {
"start": {
"line": 14,
"column": 46
},
"end": {
"line": 14,
"column": 53
},
"identifierName": "aliases"
},
"name": "aliases"
}
]
},
"property": {
"type": "Identifier",
"start": 310,
"end": 318,
"loc": {
"start": {
"line": 14,
"column": 55
},
"end": {
"line": 14,
"column": 63
},
"identifierName": "includes"
},
"name": "includes"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 319,
"end": 326,
"loc": {
"start": {
"line": 14,
"column": 64
},
"end": {
"line": 14,
"column": 71
},
"identifierName": "command"
},
"name": "command"
}
]
}
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Whether a given command is an alias\n * @param {string} command\n * @return {Boolean}\n ",
"start": 158,
"end": 254,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 13,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command name of a given alias\n * @param {string} alias\n * @return {string}\n ",
"start": 330,
"end": 424,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 20,
"column": 3
}
}
}
]
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Whether a given command is an alias\n * @param {string} command\n * @return {Boolean}\n ",
"start": 158,
"end": 254,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 13,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command name of a given alias\n * @param {string} alias\n * @return {string}\n ",
"start": 330,
"end": 424,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 20,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 425,
"end": 479,
"loc": {
"start": {
"line": 21,
"column": 0
},
"end": {
"line": 21,
"column": 54
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 432,
"end": 479,
"loc": {
"start": {
"line": 21,
"column": 7
},
"end": {
"line": 21,
"column": 54
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 438,
"end": 478,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 53
}
},
"id": {
"type": "Identifier",
"start": 438,
"end": 452,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 27
},
"identifierName": "aliasToCommand"
},
"name": "aliasToCommand",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 455,
"end": 478,
"loc": {
"start": {
"line": 21,
"column": 30
},
"end": {
"line": 21,
"column": 53
}
},
"id": {
"type": "Identifier",
"start": 438,
"end": 452,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 27
},
"identifierName": "aliasToCommand"
},
"name": "aliasToCommand",
"leadingComments": null
},
"generator": false,
"expression": true,
"async": false,
"params": [
{
"type": "Identifier",
"start": 455,
"end": 460,
"loc": {
"start": {
"line": 21,
"column": 30
},
"end": {
"line": 21,
"column": 35
},
"identifierName": "alias"
},
"name": "alias"
}
],
"body": {
"type": "MemberExpression",
"start": 464,
"end": 478,
"loc": {
"start": {
"line": 21,
"column": 39
},
"end": {
"line": 21,
"column": 53
}
},
"object": {
"type": "Identifier",
"start": 464,
"end": 471,
"loc": {
"start": {
"line": 21,
"column": 39
},
"end": {
"line": 21,
"column": 46
},
"identifierName": "aliases"
},
"name": "aliases"
},
"property": {
"type": "Identifier",
"start": 472,
"end": 477,
"loc": {
"start": {
"line": 21,
"column": 47
},
"end": {
"line": 21,
"column": 52
},
"identifierName": "alias"
},
"name": "alias"
},
"computed": true
}
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command name of a given alias\n * @param {string} alias\n * @return {string}\n ",
"start": 330,
"end": 424,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 20,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the function of a given command\n * @param {string} command command name\n * @return {Function} command function\n ",
"start": 481,
"end": 609,
"loc": {
"start": {
"line": 23,
"column": 0
},
"end": {
"line": 27,
"column": 3
}
}
}
]
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command name of a given alias\n * @param {string} alias\n * @return {string}\n ",
"start": 330,
"end": 424,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 20,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the function of a given command\n * @param {string} command command name\n * @return {Function} command function\n ",
"start": 481,
"end": 609,
"loc": {
"start": {
"line": 23,
"column": 0
},
"end": {
"line": 27,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 610,
"end": 799,
"loc": {
"start": {
"line": 28,
"column": 0
},
"end": {
"line": 36,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 617,
"end": 799,
"loc": {
"start": {
"line": 28,
"column": 7
},
"end": {
"line": 36,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 623,
"end": 798,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 36,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 623,
"end": 640,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 28,
"column": 30
},
"identifierName": "commandToFunction"
},
"name": "commandToFunction",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 643,
"end": 798,
"loc": {
"start": {
"line": 28,
"column": 33
},
"end": {
"line": 36,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 623,
"end": 640,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 28,
"column": 30
},
"identifierName": "commandToFunction"
},
"name": "commandToFunction",
"leadingComments": null
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 643,
"end": 650,
"loc": {
"start": {
"line": 28,
"column": 33
},
"end": {
"line": 28,
"column": 40
},
"identifierName": "command"
},
"name": "command"
}
],
"body": {
"type": "BlockStatement",
"start": 654,
"end": 798,
"loc": {
"start": {
"line": 28,
"column": 44
},
"end": {
"line": 36,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 658,
"end": 694,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 29,
"column": 38
}
},
"expression": {
"type": "AssignmentExpression",
"start": 658,
"end": 693,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 29,
"column": 37
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 658,
"end": 665,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 29,
"column": 9
},
"identifierName": "command"
},
"name": "command"
},
"right": {
"type": "LogicalExpression",
"start": 668,
"end": 693,
"loc": {
"start": {
"line": 29,
"column": 12
},
"end": {
"line": 29,
"column": 37
}
},
"left": {
"type": "Identifier",
"start": 668,
"end": 675,
"loc": {
"start": {
"line": 29,
"column": 12
},
"end": {
"line": 29,
"column": 19
},
"identifierName": "command"
},
"name": "command"
},
"operator": "||",
"right": {
"type": "Identifier",
"start": 679,
"end": 693,
"loc": {
"start": {
"line": 29,
"column": 23
},
"end": {
"line": 29,
"column": 37
},
"identifierName": "defaultCommand"
},
"name": "defaultCommand"
}
}
}
},
{
"type": "IfStatement",
"start": 698,
"end": 764,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 33,
"column": 3
}
},
"test": {
"type": "CallExpression",
"start": 702,
"end": 718,
"loc": {
"start": {
"line": 31,
"column": 6
},
"end": {
"line": 31,
"column": 22
}
},
"callee": {
"type": "Identifier",
"start": 702,
"end": 709,
"loc": {
"start": {
"line": 31,
"column": 6
},
"end": {
"line": 31,
"column": 13
},
"identifierName": "isAlias"
},
"name": "isAlias"
},
"arguments": [
{
"type": "Identifier",
"start": 710,
"end": 717,
"loc": {
"start": {
"line": 31,
"column": 14
},
"end": {
"line": 31,
"column": 21
},
"identifierName": "command"
},
"name": "command"
}
]
},
"consequent": {
"type": "BlockStatement",
"start": 720,
"end": 764,
"loc": {
"start": {
"line": 31,
"column": 24
},
"end": {
"line": 33,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 726,
"end": 760,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 38
}
},
"expression": {
"type": "AssignmentExpression",
"start": 726,
"end": 759,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 37
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 726,
"end": 733,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 11
},
"identifierName": "command"
},
"name": "command"
},
"right": {
"type": "CallExpression",
"start": 736,
"end": 759,
"loc": {
"start": {
"line": 32,
"column": 14
},
"end": {
"line": 32,
"column": 37
}
},
"callee": {
"type": "Identifier",
"start": 736,
"end": 750,
"loc": {
"start": {
"line": 32,
"column": 14
},
"end": {
"line": 32,
"column": 28
},
"identifierName": "aliasToCommand"
},
"name": "aliasToCommand"
},
"arguments": [
{
"type": "Identifier",
"start": 751,
"end": 758,
"loc": {
"start": {
"line": 32,
"column": 29
},
"end": {
"line": 32,
"column": 36
},
"identifierName": "command"
},
"name": "command"
}
]
}
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "ReturnStatement",
"start": 768,
"end": 796,
"loc": {
"start": {
"line": 35,
"column": 2
},
"end": {
"line": 35,
"column": 30
}
},
"argument": {
"type": "MemberExpression",
"start": 775,
"end": 795,
"loc": {
"start": {
"line": 35,
"column": 9
},
"end": {
"line": 35,
"column": 29
}
},
"object": {
"type": "Identifier",
"start": 775,
"end": 786,
"loc": {
"start": {
"line": 35,
"column": 9
},
"end": {
"line": 35,
"column": 20
},
"identifierName": "commandsMap"
},
"name": "commandsMap"
},
"property": {
"type": "Identifier",
"start": 787,
"end": 794,
"loc": {
"start": {
"line": 35,
"column": 21
},
"end": {
"line": 35,
"column": 28
},
"identifierName": "command"
},
"name": "command"
},
"computed": true
}
}
],
"directives": []
}
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the function of a given command\n * @param {string} command command name\n * @return {Function} command function\n ",
"start": 481,
"end": 609,
"loc": {
"start": {
"line": 23,
"column": 0
},
"end": {
"line": 27,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command and the arguments from the cli\n * @return {Object}\n * @property {string} command command name\n * @property {string[]} argv command arguments\n ",
"start": 801,
"end": 975,
"loc": {
"start": {
"line": 38,
"column": 0
},
"end": {
"line": 43,
"column": 3
}
}
}
]
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the function of a given command\n * @param {string} command command name\n * @return {Function} command function\n ",
"start": 481,
"end": 609,
"loc": {
"start": {
"line": 23,
"column": 0
},
"end": {
"line": 27,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get the command and the arguments from the cli\n * @return {Object}\n * @property {string} command command name\n * @property {string[]} argv command arguments\n ",
"start": 801,
"end": 975,
"loc": {
"start": {
"line": 38,
"column": 0
},
"end": {
"line": 43,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 976,
"end": 1127,
"loc": {
"start": {
"line": 44,
"column": 0
},
"end": {
"line": 48,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 983,
"end": 1127,
"loc": {
"start": {
"line": 44,
"column": 7
},
"end": {
"line": 48,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 989,
"end": 1126,
"loc": {
"start": {
"line": 44,
"column": 13
},
"end": {
"line": 48,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 989,
"end": 1013,
"loc": {
"start": {
"line": 44,
"column": 13
},
"end": {
"line": 44,
"column": 37
},
"identifierName": "getCommandAndArgvFromCli"
},
"name": "getCommandAndArgvFromCli",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 1016,
"end": 1126,
"loc": {
"start": {
"line": 44,
"column": 40
},
"end": {
"line": 48,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 989,
"end": 1013,
"loc": {
"start": {
"line": 44,
"column": 13
},
"end": {
"line": 44,
"column": 37
},
"identifierName": "getCommandAndArgvFromCli"
},
"name": "getCommandAndArgvFromCli",
"leadingComments": null
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 1022,
"end": 1126,
"loc": {
"start": {
"line": 44,
"column": 46
},
"end": {
"line": 48,
"column": 1
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 1026,
"end": 1095,
"loc": {
"start": {
"line": 45,
"column": 2
},
"end": {
"line": 45,
"column": 71
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1032,
"end": 1