mongoose-data-seed
Version:
Seed mongodb with data using mongoose models
1,579 lines (1,578 loc) • 2.21 MB
JSON
{
"type": "File",
"start": 0,
"end": 9279,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 373,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 9279,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 373,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "test"
},
"name": "test"
}
}
],
"source": {
"type": "StringLiteral",
"start": 17,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 22
}
},
"extra": {
"rawValue": "ava",
"raw": "'ava'"
},
"value": "ava"
}
},
{
"type": "ImportDeclaration",
"start": 24,
"end": 50,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 26
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 31,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 31,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "sinon"
},
"name": "sinon"
}
}
],
"source": {
"type": "StringLiteral",
"start": 42,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 25
}
},
"extra": {
"rawValue": "sinon",
"raw": "'sinon'"
},
"value": "sinon"
}
},
{
"type": "ImportDeclaration",
"start": 51,
"end": 92,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 41
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 60,
"end": 67,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 16
}
},
"imported": {
"type": "Identifier",
"start": 60,
"end": 67,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 16
},
"identifierName": "toArray"
},
"name": "toArray"
},
"local": {
"type": "Identifier",
"start": 60,
"end": 67,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 16
},
"identifierName": "toArray"
},
"name": "toArray"
}
}
],
"source": {
"type": "StringLiteral",
"start": 75,
"end": 91,
"loc": {
"start": {
"line": 3,
"column": 24
},
"end": {
"line": 3,
"column": 40
}
},
"extra": {
"rawValue": "rxjs/operators",
"raw": "'rxjs/operators'"
},
"value": "rxjs/operators"
}
},
{
"type": "ImportDeclaration",
"start": 94,
"end": 160,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 66
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 103,
"end": 114,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 20
}
},
"imported": {
"type": "Identifier",
"start": 103,
"end": 114,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 20
},
"identifierName": "mockImports"
},
"name": "mockImports"
},
"local": {
"type": "Identifier",
"start": 103,
"end": 114,
"loc": {
"start": {
"line": 5,
"column": 9
},
"end": {
"line": 5,
"column": 20
},
"identifierName": "mockImports"
},
"name": "mockImports"
}
},
{
"type": "ImportSpecifier",
"start": 116,
"end": 128,
"loc": {
"start": {
"line": 5,
"column": 22
},
"end": {
"line": 5,
"column": 34
}
},
"imported": {
"type": "Identifier",
"start": 116,
"end": 128,
"loc": {
"start": {
"line": 5,
"column": 22
},
"end": {
"line": 5,
"column": 34
},
"identifierName": "resetImports"
},
"name": "resetImports"
},
"local": {
"type": "Identifier",
"start": 116,
"end": 128,
"loc": {
"start": {
"line": 5,
"column": 22
},
"end": {
"line": 5,
"column": 34
},
"identifierName": "resetImports"
},
"name": "resetImports"
}
}
],
"source": {
"type": "StringLiteral",
"start": 136,
"end": 159,
"loc": {
"start": {
"line": 5,
"column": 42
},
"end": {
"line": 5,
"column": 65
}
},
"extra": {
"rawValue": "../utils/test-helpers",
"raw": "'../utils/test-helpers'"
},
"value": "../utils/test-helpers"
}
},
{
"type": "ImportDeclaration",
"start": 162,
"end": 217,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 55
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 169,
"end": 186,
"loc": {
"start": {
"line": 7,
"column": 7
},
"end": {
"line": 7,
"column": 24
}
},
"local": {
"type": "Identifier",
"start": 169,
"end": 186,
"loc": {
"start": {
"line": 7,
"column": 7
},
"end": {
"line": 7,
"column": 24
},
"identifierName": "MdSeedRunnerError"
},
"name": "MdSeedRunnerError"
}
}
],
"source": {
"type": "StringLiteral",
"start": 192,
"end": 216,
"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"
}
},
{
"type": "ImportDeclaration",
"start": 219,
"end": 304,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 11,
"column": 26
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 226,
"end": 238,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 9,
"column": 19
}
},
"local": {
"type": "Identifier",
"start": 226,
"end": 238,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 9,
"column": 19
},
"identifierName": "MdSeedRunner"
},
"name": "MdSeedRunner"
}
},
{
"type": "ImportSpecifier",
"start": 244,
"end": 276,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 34
}
},
"imported": {
"type": "Identifier",
"start": 244,
"end": 257,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 15
},
"identifierName": "__RewireAPI__"
},
"name": "__RewireAPI__"
},
"local": {
"type": "Identifier",
"start": 261,
"end": 276,
"loc": {
"start": {
"line": 10,
"column": 19
},
"end": {
"line": 10,
"column": 34
},
"identifierName": "moduleRewireAPI"
},
"name": "moduleRewireAPI"
}
}
],
"source": {
"type": "StringLiteral",
"start": 285,
"end": 303,
"loc": {
"start": {
"line": 11,
"column": 7
},
"end": {
"line": 11,
"column": 25
}
},
"extra": {
"rawValue": "./md-seed-runner",
"raw": "'./md-seed-runner'"
},
"value": "./md-seed-runner"
}
},
{
"type": "VariableDeclaration",
"start": 306,
"end": 474,
"loc": {
"start": {
"line": 13,
"column": 0
},
"end": {
"line": 20,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 312,
"end": 473,
"loc": {
"start": {
"line": 13,
"column": 6
},
"end": {
"line": 20,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 312,
"end": 320,
"loc": {
"start": {
"line": 13,
"column": 6
},
"end": {
"line": 13,
"column": 14
},
"identifierName": "helpData"
},
"name": "helpData"
},
"init": {
"type": "ObjectExpression",
"start": 323,
"end": 473,
"loc": {
"start": {
"line": 13,
"column": 17
},
"end": {
"line": 20,
"column": 1
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 327,
"end": 359,
"loc": {
"start": {
"line": 14,
"column": 2
},
"end": {
"line": 14,
"column": 34
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 327,
"end": 334,
"loc": {
"start": {
"line": 14,
"column": 2
},
"end": {
"line": 14,
"column": 9
},
"identifierName": "connect"
},
"name": "connect"
},
"value": {
"type": "CallExpression",
"start": 336,
"end": 359,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 34
}
},
"callee": {
"type": "MemberExpression",
"start": 336,
"end": 357,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 32
}
},
"object": {
"type": "CallExpression",
"start": 336,
"end": 348,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 23
}
},
"callee": {
"type": "MemberExpression",
"start": 336,
"end": 346,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 21
}
},
"object": {
"type": "Identifier",
"start": 336,
"end": 341,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 16
},
"identifierName": "sinon"
},
"name": "sinon"
},
"property": {
"type": "Identifier",
"start": 342,
"end": 346,
"loc": {
"start": {
"line": 14,
"column": 17
},
"end": {
"line": 14,
"column": 21
},
"identifierName": "stub"
},
"name": "stub"
},
"computed": false
},
"arguments": []
},
"property": {
"type": "Identifier",
"start": 349,
"end": 357,
"loc": {
"start": {
"line": 14,
"column": 24
},
"end": {
"line": 14,
"column": 32
},
"identifierName": "resolves"
},
"name": "resolves"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ObjectProperty",
"start": 363,
"end": 394,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 33
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 363,
"end": 369,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 8
},
"identifierName": "dropdb"
},
"name": "dropdb"
},
"value": {
"type": "CallExpression",
"start": 371,
"end": 394,
"loc": {
"start": {
"line": 15,
"column": 10
},
"end": {
"line": 15,
"column": 33
}
},
"callee": {
"type": "MemberExpression",
"start": 371,
"end": 392,
"loc": {
"start": {
"line": 15,
"column": 10
},
"end": {
"line": 15,
"column": 31
}
},
"object": {
"type": "CallExpression",
"start": 371,
"end": 383,
"loc": {
"start": {
"line": 15,
"column": 10
},
"end": {
"line": 15,
"column": 22
}
},
"callee": {
"type": "MemberExpression",
"start": 371,
"end": 381,
"loc": {
"start": {
"line": 15,
"column": 10
},
"end": {
"line": 15,
"column": 20
}
},
"object": {
"type": "Identifier",
"start": 371,
"end": 376,
"loc": {
"start": {
"line": 15,
"column": 10
},
"end": {
"line": 15,
"column": 15
},
"identifierName": "sinon"
},
"name": "sinon"
},
"property": {
"type": "Identifier",
"start": 377,
"end": 381,
"loc": {
"start": {
"line": 15,
"column": 16
},
"end": {
"line": 15,
"column": 20
},
"identifierName": "stub"
},
"name": "stub"
},
"computed": false
},
"arguments": []
},
"property": {
"type": "Identifier",
"start": 384,
"end": 392,
"loc": {
"start": {
"line": 15,
"column": 23
},
"end": {
"line": 15,
"column": 31
},
"identifierName": "resolves"
},
"name": "resolves"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ObjectProperty",
"start": 398,
"end": 470,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 19,
"column": 3
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 398,
"end": 409,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 16,
"column": 13
},
"identifierName": "seedersList"
},
"name": "seedersList"
},
"value": {
"type": "ObjectExpression",
"start": 411,
"end": 470,
"loc": {
"start": {
"line": 16,
"column": 15
},
"end": {
"line": 19,
"column": 3
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 417,
"end": 438,
"loc": {
"start": {
"line": 17,
"column": 4
},
"end": {
"line": 17,
"column": 25
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 417,
"end": 422,
"loc": {
"start": {
"line": 17,
"column": 4
},
"end": {
"line": 17,
"column": 9
},
"identifierName": "Users"
},
"name": "Users"
},
"value": {
"type": "StringLiteral",
"start": 424,
"end": 438,
"loc": {
"start": {
"line": 17,
"column": 11
},
"end": {
"line": 17,
"column": 25
}
},
"extra": {
"rawValue": "users-seeder",
"raw": "'users-seeder'"
},
"value": "users-seeder"
}
},
{
"type": "ObjectProperty",
"start": 444,
"end": 465,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 25
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 444,
"end": 449,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 9
},
"identifierName": "Posts"
},
"name": "Posts"
},
"value": {
"type": "StringLiteral",
"start": 451,
"end": 465,
"loc": {
"start": {
"line": 18,
"column": 11
},
"end": {
"line": 18,
"column": 25
}
},
"extra": {
"rawValue": "posts-seeder",
"raw": "'posts-seeder'"
},
"value": "posts-seeder"
}
}
]
}
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"start": 476,
"end": 709,
"loc": {
"start": {
"line": 22,
"column": 0
},
"end": {
"line": 31,
"column": 3
}
},
"expression": {
"type": "CallExpression",
"start": 476,
"end": 708,
"loc": {
"start": {
"line": 22,
"column": 0
},
"end": {
"line": 31,
"column": 2
}
},
"callee": {
"type": "MemberExpression",
"start": 476,
"end": 491,
"loc": {
"start": {
"line": 22,
"column": 0
},
"end": {
"line": 22,
"column": 15
}
},
"object": {
"type": "Identifier",
"start": 476,
"end": 480,
"loc": {
"start": {
"line": 22,
"column": 0
},
"end": {
"line": 22,
"column": 4
},
"identifierName": "test"
},
"name": "test"
},
"property": {
"type": "Identifier",
"start": 481,
"end": 491,
"loc": {
"start": {
"line": 22,
"column": 5
},
"end": {
"line": 22,
"column": 15
},
"identifierName": "beforeEach"
},
"name": "beforeEach"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 492,
"end": 506,
"loc": {
"start": {
"line": 22,
"column": 16
},
"end": {
"line": 22,
"column": 30
}
},
"extra": {
"rawValue": "mock imports",
"raw": "'mock imports'"
},
"value": "mock imports"
},
{
"type": "ArrowFunctionExpression",
"start": 508,
"end": 707,
"loc": {
"start": {
"line": 22,
"column": 32
},
"end": {
"line": 31,
"column": 1
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 508,
"end": 509,
"loc": {
"start": {
"line": 22,
"column": 32
},
"end": {
"line": 22,
"column": 33
},
"identifierName": "t"
},
"name": "t"
}
],
"body": {
"type": "BlockStatement",
"start": 513,
"end": 707,
"loc": {
"start": {
"line": 22,
"column": 37
},
"end": {
"line": 31,
"column": 1
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 517,
"end": 635,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 26,
"column": 4
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 523,
"end": 634,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 26,
"column": 3
}
},
"id": {
"type": "Identifier",
"start": 523,
"end": 528,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 13
},
"identifierName": "mocks"
},
"name": "mocks"
},
"init": {
"type": "ObjectExpression",
"start": 531,
"end": 634,
"loc": {
"start": {
"line": 23,
"column": 16
},
"end": {
"line": 26,
"column": 3
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 537,
"end": 576,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 24,
"column": 43
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 537,
"end": 562,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 24,
"column": 29
},
"identifierName": "getObjectWithSelectedKeys"
},
"name": "getObjectWithSelectedKeys"
},
"value": {
"type": "CallExpression",
"start": 564,
"end": 576,
"loc": {
"start": {
"line": 24,
"column": 31
},
"end": {
"line": 24,
"column": 43
}
},
"callee": {
"type": "MemberExpression",
"start": 564,
"end": 574,
"loc": {
"start": {
"line": 24,
"column": 31
},
"end": {
"line": 24,
"column": 41
}
},
"object": {
"type": "Identifier",
"start": 564,
"end": 569,
"loc": {
"start": {
"line": 24,
"column": 31
},
"end": {
"line": 24,
"column": 36
},
"identifierName": "sinon"
},
"name": "sinon"
},
"property": {
"type": "Identifier",
"start": 570,
"end": 574,
"loc": {
"start": {
"line": 24,
"column": 37
},
"end": {
"line": 24,
"column": 41
},
"identifierName": "stub"
},
"name": "stub"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ObjectProperty",
"start": 582,
"end": 629,
"loc": {
"start": {
"line": 25,
"column": 4
},
"end": {
"line": 25,
"column": 51
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 582,
"end": 601,
"loc": {
"start": {
"line": 25,
"column": 4
},
"end": {
"line": 25,
"column": 23
},
"identifierName": "normalizeSeederName"
},
"name": "normalizeSeederName"
},
"value": {
"type": "CallExpression",
"start": 603,
"end": 629,
"loc": {
"start": {
"line": 25,
"column": 25
},
"end": {
"line": 25,
"column": 51
}
},
"callee": {
"type": "MemberExpression",
"start": 603,
"end": 626,
"loc": {
"start": {
"line": 25,
"column": 25
},
"end": {
"line": 25,
"column": 48
}
},
"object": {
"type": "CallExpression",
"start": 603,
"end": 615,
"loc": {
"start": {
"line": 25,
"column": 25
},
"end": {
"line": 25,
"column": 37
}
},
"callee": {
"type": "MemberExpression",
"start": 603,
"end": 613,
"loc": {
"start": {
"line": 25,
"column": 25
},
"end": {
"line": 25,
"column": 35
}
},
"object": {
"type": "Identifier",
"start": 603,
"end": 608,
"loc": {
"start": {
"line": 25,
"column": 25
},
"end": {
"line": 25,
"column": 30
},
"identifierName": "sinon"
},
"name": "sinon"
},
"property": {
"type": "Identifier",
"start": 609,
"end": 613,
"loc": {
"start": {
"line": 25,
"column": 31
},
"end": {
"line": 25,
"column": 35
},
"identifierName": "stub"
},
"name": "stub"
},
"computed": false
},
"arguments": []
},
"property": {
"type": "Identifier",
"start": 616,
"end": 626,
"loc": {
"start": {
"line": 25,
"column": 38
},
"end": {
"line": 25,
"column": 48
},
"identifierName": "returnsArg"
},
"name": "returnsArg"
},
"computed": false
},
"arguments": [
{
"type": "NumericLiteral",
"start": 627,
"end": 628,
"loc": {
"start": {
"line": 25,
"column": 49
},
"end": {
"line": 25,
"column": 50