mongoose-data-seed
Version:
Seed mongodb with data using mongoose models
1,493 lines (1,492 loc) • 162 kB
JSON
{
"type": "File",
"start": 0,
"end": 1226,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 47,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1226,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 47,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 48,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 48
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 22
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 22
},
"identifierName": "commandLineArgs"
},
"name": "commandLineArgs"
}
}
],
"source": {
"type": "StringLiteral",
"start": 28,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 47
}
},
"extra": {
"rawValue": "command-line-args",
"raw": "'command-line-args'"
},
"value": "command-line-args"
}
},
{
"type": "ImportDeclaration",
"start": 49,
"end": 75,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 26
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 56,
"end": 61,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 56,
"end": 61,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "chalk"
},
"name": "chalk"
}
}
],
"source": {
"type": "StringLiteral",
"start": 67,
"end": 74,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 25
}
},
"extra": {
"rawValue": "chalk",
"raw": "'chalk'"
},
"value": "chalk"
}
},
{
"type": "ImportDeclaration",
"start": 76,
"end": 106,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 30
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 85,
"end": 89,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
}
},
"imported": {
"type": "Identifier",
"start": 85,
"end": 89,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "trim"
},
"name": "trim"
},
"local": {
"type": "Identifier",
"start": 85,
"end": 89,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "trim"
},
"name": "trim"
}
}
],
"source": {
"type": "StringLiteral",
"start": 97,
"end": 105,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 29
}
},
"extra": {
"rawValue": "lodash",
"raw": "'lodash'"
},
"value": "lodash"
}
},
{
"type": "ImportDeclaration",
"start": 108,
"end": 134,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 26
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 115,
"end": 119,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
}
},
"local": {
"type": "Identifier",
"start": 115,
"end": 119,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "help"
},
"name": "help"
}
}
],
"source": {
"type": "StringLiteral",
"start": 125,
"end": 133,
"loc": {
"start": {
"line": 5,
"column": 17
},
"end": {
"line": 5,
"column": 25
}
},
"extra": {
"rawValue": "./help",
"raw": "'./help'"
},
"value": "./help"
}
},
{
"type": "ImportDeclaration",
"start": 135,
"end": 188,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 53
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 142,
"end": 159,
"loc": {
"start": {
"line": 6,
"column": 7
},
"end": {
"line": 6,
"column": 24
}
},
"local": {
"type": "Identifier",
"start": 142,
"end": 159,
"loc": {
"start": {
"line": 6,
"column": 7
},
"end": {
"line": 6,
"column": 24
},
"identifierName": "optionDefinitions"
},
"name": "optionDefinitions"
}
}
],
"source": {
"type": "StringLiteral",
"start": 165,
"end": 187,
"loc": {
"start": {
"line": 6,
"column": 30
},
"end": {
"line": 6,
"column": 52
}
},
"extra": {
"rawValue": "./option-definitions",
"raw": "'./option-definitions'"
},
"value": "./option-definitions"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get generate options from argv\n * @param {string[]} argv cli argv\n * @return {Object} run options\n * @property {string} seederName\n * @property {boolean} helpWanted\n ",
"start": 190,
"end": 406,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 14,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 407,
"end": 647,
"loc": {
"start": {
"line": 15,
"column": 0
},
"end": {
"line": 26,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 414,
"end": 647,
"loc": {
"start": {
"line": 15,
"column": 7
},
"end": {
"line": 26,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 420,
"end": 646,
"loc": {
"start": {
"line": 15,
"column": 13
},
"end": {
"line": 26,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 420,
"end": 430,
"loc": {
"start": {
"line": 15,
"column": 13
},
"end": {
"line": 15,
"column": 23
},
"identifierName": "getOptions"
},
"name": "getOptions",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 433,
"end": 646,
"loc": {
"start": {
"line": 15,
"column": 26
},
"end": {
"line": 26,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 420,
"end": 430,
"loc": {
"start": {
"line": 15,
"column": 13
},
"end": {
"line": 15,
"column": 23
},
"identifierName": "getOptions"
},
"name": "getOptions",
"leadingComments": null
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 433,
"end": 437,
"loc": {
"start": {
"line": 15,
"column": 26
},
"end": {
"line": 15,
"column": 30
},
"identifierName": "argv"
},
"name": "argv"
}
],
"body": {
"type": "BlockStatement",
"start": 441,
"end": 646,
"loc": {
"start": {
"line": 15,
"column": 34
},
"end": {
"line": 26,
"column": 1
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 445,
"end": 549,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 19,
"column": 4
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 451,
"end": 548,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 19,
"column": 3
}
},
"id": {
"type": "ObjectPattern",
"start": 451,
"end": 489,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 46
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 453,
"end": 469,
"loc": {
"start": {
"line": 16,
"column": 10
},
"end": {
"line": 16,
"column": 26
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 453,
"end": 457,
"loc": {
"start": {
"line": 16,
"column": 10
},
"end": {
"line": 16,
"column": 14
},
"identifierName": "name"
},
"name": "name"
},
"value": {
"type": "Identifier",
"start": 459,
"end": 469,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 26
},
"identifierName": "seederName"
},
"name": "seederName"
}
},
{
"type": "ObjectProperty",
"start": 471,
"end": 487,
"loc": {
"start": {
"line": 16,
"column": 28
},
"end": {
"line": 16,
"column": 44
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 471,
"end": 475,
"loc": {
"start": {
"line": 16,
"column": 28
},
"end": {
"line": 16,
"column": 32
},
"identifierName": "help"
},
"name": "help"
},
"value": {
"type": "Identifier",
"start": 477,
"end": 487,
"loc": {
"start": {
"line": 16,
"column": 34
},
"end": {
"line": 16,
"column": 44
},
"identifierName": "helpWanted"
},
"name": "helpWanted"
}
}
]
},
"init": {
"type": "CallExpression",
"start": 492,
"end": 548,
"loc": {
"start": {
"line": 16,
"column": 49
},
"end": {
"line": 19,
"column": 3
}
},
"callee": {
"type": "Identifier",
"start": 492,
"end": 507,
"loc": {
"start": {
"line": 16,
"column": 49
},
"end": {
"line": 16,
"column": 64
},
"identifierName": "commandLineArgs"
},
"name": "commandLineArgs"
},
"arguments": [
{
"type": "Identifier",
"start": 513,
"end": 530,
"loc": {
"start": {
"line": 17,
"column": 4
},
"end": {
"line": 17,
"column": 21
},
"identifierName": "optionDefinitions"
},
"name": "optionDefinitions"
},
{
"type": "ObjectExpression",
"start": 536,
"end": 544,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 12
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 538,
"end": 542,
"loc": {
"start": {
"line": 18,
"column": 6
},
"end": {
"line": 18,
"column": 10
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 538,
"end": 542,
"loc": {
"start": {
"line": 18,
"column": 6
},
"end": {
"line": 18,
"column": 10
},
"identifierName": "argv"
},
"name": "argv"
},
"value": {
"type": "Identifier",
"start": 538,
"end": 542,
"loc": {
"start": {
"line": 18,
"column": 6
},
"end": {
"line": 18,
"column": 10
},
"identifierName": "argv"
},
"name": "argv"
},
"extra": {
"shorthand": true
}
}
]
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"start": 553,
"end": 596,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 45
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 559,
"end": 595,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 44
}
},
"id": {
"type": "Identifier",
"start": 559,
"end": 566,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 15
},
"identifierName": "options"
},
"name": "options"
},
"init": {
"type": "ObjectExpression",
"start": 569,
"end": 595,
"loc": {
"start": {
"line": 21,
"column": 18
},
"end": {
"line": 21,
"column": 44
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 571,
"end": 581,
"loc": {
"start": {
"line": 21,
"column": 20
},
"end": {
"line": 21,
"column": 30
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 571,
"end": 581,
"loc": {
"start": {
"line": 21,
"column": 20
},
"end": {
"line": 21,
"column": 30
},
"identifierName": "seederName"
},
"name": "seederName"
},
"value": {
"type": "Identifier",
"start": 571,
"end": 581,
"loc": {
"start": {
"line": 21,
"column": 20
},
"end": {
"line": 21,
"column": 30
},
"identifierName": "seederName"
},
"name": "seederName"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 583,
"end": 593,
"loc": {
"start": {
"line": 21,
"column": 32
},
"end": {
"line": 21,
"column": 42
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 583,
"end": 593,
"loc": {
"start": {
"line": 21,
"column": 32
},
"end": {
"line": 21,
"column": 42
},
"identifierName": "helpWanted"
},
"name": "helpWanted"
},
"value": {
"type": "Identifier",
"start": 583,
"end": 593,
"loc": {
"start": {
"line": 21,
"column": 32
},
"end": {
"line": 21,
"column": 42
},
"identifierName": "helpWanted"
},
"name": "helpWanted"
},
"extra": {
"shorthand": true
}
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"start": 600,
"end": 625,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 23,
"column": 27
}
},
"expression": {
"type": "CallExpression",
"start": 600,
"end": 624,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 23,
"column": 26
}
},
"callee": {
"type": "Identifier",
"start": 600,
"end": 615,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 23,
"column": 17
},
"identifierName": "validateOptions"
},
"name": "validateOptions"
},
"arguments": [
{
"type": "Identifier",
"start": 616,
"end": 623,
"loc": {
"start": {
"line": 23,
"column": 18
},
"end": {
"line": 23,
"column": 25
},
"identifierName": "options"
},
"name": "options"
}
]
}
},
{
"type": "ReturnStatement",
"start": 629,
"end": 644,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 25,
"column": 17
}
},
"argument": {
"type": "Identifier",
"start": 636,
"end": 643,
"loc": {
"start": {
"line": 25,
"column": 9
},
"end": {
"line": 25,
"column": 16
},
"identifierName": "options"
},
"name": "options"
}
}
],
"directives": []
}
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get generate options from argv\n * @param {string[]} argv cli argv\n * @return {Object} run options\n * @property {string} seederName\n * @property {boolean} helpWanted\n ",
"start": 190,
"end": 406,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 14,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Validate generate command options\n * @param {Object} [options={}] Options\n * @param {string} options.seederName seeder name to generate\n * @param {boolean} options.helpWanted help wanted?\n * @throws {Error} throw error when options are not valid.\n ",
"start": 649,
"end": 917,
"loc": {
"start": {
"line": 28,
"column": 0
},
"end": {
"line": 34,
"column": 3
}
}
}
]
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Get generate options from argv\n * @param {string[]} argv cli argv\n * @return {Object} run options\n * @property {string} seederName\n * @property {boolean} helpWanted\n ",
"start": 190,
"end": 406,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 14,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Validate generate command options\n * @param {Object} [options={}] Options\n * @param {string} options.seederName seeder name to generate\n * @param {boolean} options.helpWanted help wanted?\n * @throws {Error} throw error when options are not valid.\n ",
"start": 649,
"end": 917,
"loc": {
"start": {
"line": 28,
"column": 0
},
"end": {
"line": 34,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 918,
"end": 1225,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 46,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 925,
"end": 1225,
"loc": {
"start": {
"line": 35,
"column": 7
},
"end": {
"line": 46,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 931,
"end": 1224,
"loc": {
"start": {
"line": 35,
"column": 13
},
"end": {
"line": 46,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 931,
"end": 946,
"loc": {
"start": {
"line": 35,
"column": 13
},
"end": {
"line": 35,
"column": 28
},
"identifierName": "validateOptions"
},
"name": "validateOptions",
"leadingComments": null
},
"init": {
"type": "ArrowFunctionExpression",
"start": 949,
"end": 1224,
"loc": {
"start": {
"line": 35,
"column": 31
},
"end": {
"line": 46,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 931,
"end": 946,
"loc": {
"start": {
"line": 35,
"column": 13
},
"end": {
"line": 35,
"column": 28
},
"identifierName": "validateOptions"
},
"name": "validateOptions",
"leadingComments": null
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 950,
"end": 981,
"loc": {
"start": {
"line": 35,
"column": 32
},
"end": {
"line": 35,
"column": 63
}
},
"left": {
"type": "ObjectPattern",
"start": 950,
"end": 976,
"loc": {
"start": {
"line": 35,
"column": 32
},
"end": {
"line": 35,
"column": 58
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 952,
"end": 962,
"loc": {
"start": {
"line": 35,
"column": 34
},
"end": {
"line": 35,
"column": 44
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 952,
"end": 962,
"loc": {
"start": {
"line": 35,
"column": 34
},
"end": {
"line": 35,
"column": 44
},
"identifierName": "seederName"
},
"name": "seederName"
},
"value": {
"type": "Identifier",
"start": 952,
"end": 962,
"loc": {
"start": {
"line": 35,
"column": 34
},
"end": {
"line": 35,
"column": 44
},
"identifierName": "seederName"
},
"name": "seederName"
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start": 964,
"end": 974,
"loc": {
"start": {
"line": 35,
"column": 46
},
"end": {
"line": 35,
"column": 56
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 964,
"end": 974,
"loc": {
"start": {
"line": 35,
"column": 46
},
"end": {
"line": 35,
"column": 56
},
"identifierName": "helpWanted"
},
"name": "helpWanted"
},
"value": {
"type": "Identifier",
"start": 964,
"end": 974,
"loc": {
"start": {
"line": 35,
"column": 46
},
"end": {
"line": 35,
"column": 56
},
"identifierName": "helpWanted"
},
"name": "helpWanted"
},
"extra": {
"shorthand": true
}
}
]
},
"right": {
"type": "ObjectExpression",
"start": 979,
"end": 981,
"loc": {
"start": {
"line": 35,
"column": 61
},
"end": {
"line": 35,
"column": 63
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 986,
"end": 1224,
"loc": {
"start": {
"line": 35,
"column": 68
},
"end": {
"line": 46,
"column": 1
}
},
"body": [
{
"type": "IfStatement",
"start": 990,
"end": 1222,
"loc": {
"start": {
"line": 36,
"column": 2
},
"end": {
"line": 45,
"column": 3
}
},
"test": {
"type": "LogicalExpression",
"start": 999,
"end": 1081,
"loc": {
"start": {
"line": 37,
"column": 4
},
"end": {
"line": 38,
"column": 67
}
},
"left": {
"type": "UnaryExpression",
"start": 999,
"end": 1010,
"loc": {
"start": {
"line": 37,
"column": 4
},
"end": {
"line": 37,
"column": 15
}
},
"operator": "!",