UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,630 lines 480 kB
{ "type": "File", "start": 0, "end": 2140, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 92, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2140, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 92, "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": 52, "end": 121, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 69 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 61, "end": 72, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 20 } }, "imported": { "type": "Identifier", "start": 61, "end": 72, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 20 }, "identifierName": "mockImports" }, "name": "mockImports" }, "local": { "type": "Identifier", "start": 61, "end": 72, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 20 }, "identifierName": "mockImports" }, "name": "mockImports" } }, { "type": "ImportSpecifier", "start": 74, "end": 86, "loc": { "start": { "line": 4, "column": 22 }, "end": { "line": 4, "column": 34 } }, "imported": { "type": "Identifier", "start": 74, "end": 86, "loc": { "start": { "line": 4, "column": 22 }, "end": { "line": 4, "column": 34 }, "identifierName": "resetImports" }, "name": "resetImports" }, "local": { "type": "Identifier", "start": 74, "end": 86, "loc": { "start": { "line": 4, "column": 22 }, "end": { "line": 4, "column": 34 }, "identifierName": "resetImports" }, "name": "resetImports" } } ], "source": { "type": "StringLiteral", "start": 94, "end": 120, "loc": { "start": { "line": 4, "column": 42 }, "end": { "line": 4, "column": 68 } }, "extra": { "rawValue": "../../utils/test-helpers", "raw": "'../../utils/test-helpers'" }, "value": "../../utils/test-helpers" } }, { "type": "ImportDeclaration", "start": 123, "end": 186, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 63 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 130, "end": 142, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 19 } }, "local": { "type": "Identifier", "start": 130, "end": 142, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 19 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" } } ], "source": { "type": "StringLiteral", "start": 148, "end": 185, "loc": { "start": { "line": 6, "column": 25 }, "end": { "line": 6, "column": 62 } }, "extra": { "rawValue": "../../core/__mocks__/md-seed-runner", "raw": "'../../core/__mocks__/md-seed-runner'" }, "value": "../../core/__mocks__/md-seed-runner" } }, { "type": "ImportDeclaration", "start": 187, "end": 234, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 47 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 194, "end": 203, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 16 } }, "local": { "type": "Identifier", "start": 194, "end": 203, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 16 }, "identifierName": "RunLogger" }, "name": "RunLogger" } } ], "source": { "type": "StringLiteral", "start": 209, "end": 233, "loc": { "start": { "line": 7, "column": 22 }, "end": { "line": 7, "column": 46 } }, "extra": { "rawValue": "./__mocks__/run-logger", "raw": "'./__mocks__/run-logger'" }, "value": "./__mocks__/run-logger" } }, { "type": "ImportDeclaration", "start": 236, "end": 298, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 62 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 243, "end": 246, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 10 } }, "local": { "type": "Identifier", "start": 243, "end": 246, "loc": { "start": { "line": 9, "column": 7 }, "end": { "line": 9, "column": 10 }, "identifierName": "run" }, "name": "run" } }, { "type": "ImportSpecifier", "start": 250, "end": 282, "loc": { "start": { "line": 9, "column": 14 }, "end": { "line": 9, "column": 46 } }, "imported": { "type": "Identifier", "start": 250, "end": 263, "loc": { "start": { "line": 9, "column": 14 }, "end": { "line": 9, "column": 27 }, "identifierName": "__RewireAPI__" }, "name": "__RewireAPI__" }, "local": { "type": "Identifier", "start": 267, "end": 282, "loc": { "start": { "line": 9, "column": 31 }, "end": { "line": 9, "column": 46 }, "identifierName": "moduleRewireAPI" }, "name": "moduleRewireAPI" } } ], "source": { "type": "StringLiteral", "start": 290, "end": 297, "loc": { "start": { "line": 9, "column": 54 }, "end": { "line": 9, "column": 61 } }, "extra": { "rawValue": "./run", "raw": "'./run'" }, "value": "./run" } }, { "type": "VariableDeclaration", "start": 300, "end": 430, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 15, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 306, "end": 429, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 15, "column": 1 } }, "id": { "type": "Identifier", "start": 306, "end": 316, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 16 }, "identifierName": "userConfig" }, "name": "userConfig" }, "init": { "type": "ObjectExpression", "start": 319, "end": 429, "loc": { "start": { "line": 11, "column": 19 }, "end": { "line": 15, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 323, "end": 355, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 34 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 323, "end": 330, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 9 }, "identifierName": "connect" }, "name": "connect" }, "value": { "type": "CallExpression", "start": 332, "end": 355, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 34 } }, "callee": { "type": "MemberExpression", "start": 332, "end": 353, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 32 } }, "object": { "type": "CallExpression", "start": 332, "end": 344, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 23 } }, "callee": { "type": "MemberExpression", "start": 332, "end": 342, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 21 } }, "object": { "type": "Identifier", "start": 332, "end": 337, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 16 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 338, "end": 342, "loc": { "start": { "line": 12, "column": 17 }, "end": { "line": 12, "column": 21 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [] }, "property": { "type": "Identifier", "start": 345, "end": 353, "loc": { "start": { "line": 12, "column": 24 }, "end": { "line": 12, "column": 32 }, "identifierName": "resolves" }, "name": "resolves" }, "computed": false }, "arguments": [] } }, { "type": "ObjectProperty", "start": 359, "end": 390, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 33 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 359, "end": 365, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 8 }, "identifierName": "dropdb" }, "name": "dropdb" }, "value": { "type": "CallExpression", "start": 367, "end": 390, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 33 } }, "callee": { "type": "MemberExpression", "start": 367, "end": 388, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 31 } }, "object": { "type": "CallExpression", "start": 367, "end": 379, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 22 } }, "callee": { "type": "MemberExpression", "start": 367, "end": 377, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 20 } }, "object": { "type": "Identifier", "start": 367, "end": 372, "loc": { "start": { "line": 13, "column": 10 }, "end": { "line": 13, "column": 15 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 373, "end": 377, "loc": { "start": { "line": 13, "column": 16 }, "end": { "line": 13, "column": 20 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [] }, "property": { "type": "Identifier", "start": 380, "end": 388, "loc": { "start": { "line": 13, "column": 23 }, "end": { "line": 13, "column": 31 }, "identifierName": "resolves" }, "name": "resolves" }, "computed": false }, "arguments": [] } }, { "type": "ObjectProperty", "start": 394, "end": 426, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 34 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 394, "end": 405, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 13 }, "identifierName": "seedersList" }, "name": "seedersList" }, "value": { "type": "StringLiteral", "start": 407, "end": 426, "loc": { "start": { "line": 14, "column": 15 }, "end": { "line": 14, "column": 34 } }, "extra": { "rawValue": "some-seeders-list", "raw": "'some-seeders-list'" }, "value": "some-seeders-list" } } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 432, "end": 487, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 19, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 438, "end": 486, "loc": { "start": { "line": 17, "column": 6 }, "end": { "line": 19, "column": 1 } }, "id": { "type": "Identifier", "start": 438, "end": 444, "loc": { "start": { "line": 17, "column": 6 }, "end": { "line": 17, "column": 12 }, "identifierName": "config" }, "name": "config" }, "init": { "type": "ObjectExpression", "start": 447, "end": 486, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 19, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 451, "end": 483, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 34 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 451, "end": 465, "loc": { "start": { "line": 18, "column": 2 }, "end": { "line": 18, "column": 16 }, "identifierName": "loadUserConfig" }, "name": "loadUserConfig" }, "value": { "type": "ArrowFunctionExpression", "start": 467, "end": 483, "loc": { "start": { "line": 18, "column": 18 }, "end": { "line": 18, "column": 34 } }, "id": null, "generator": false, "expression": true, "async": false, "params": [], "body": { "type": "Identifier", "start": 473, "end": 483, "loc": { "start": { "line": 18, "column": 24 }, "end": { "line": 18, "column": 34 }, "identifierName": "userConfig" }, "name": "userConfig" } } } ] } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 489, "end": 707, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 32, "column": 3 } }, "expression": { "type": "CallExpression", "start": 489, "end": 706, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 32, "column": 2 } }, "callee": { "type": "MemberExpression", "start": 489, "end": 504, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 15 } }, "object": { "type": "Identifier", "start": 489, "end": 493, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 4 }, "identifierName": "test" }, "name": "test" }, "property": { "type": "Identifier", "start": 494, "end": 504, "loc": { "start": { "line": 21, "column": 5 }, "end": { "line": 21, "column": 15 }, "identifierName": "beforeEach" }, "name": "beforeEach" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 505, "end": 519, "loc": { "start": { "line": 21, "column": 16 }, "end": { "line": 21, "column": 30 } }, "extra": { "rawValue": "mock imports", "raw": "'mock imports'" }, "value": "mock imports" }, { "type": "ArrowFunctionExpression", "start": 521, "end": 705, "loc": { "start": { "line": 21, "column": 32 }, "end": { "line": 32, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 521, "end": 522, "loc": { "start": { "line": 21, "column": 32 }, "end": { "line": 21, "column": 33 }, "identifierName": "t" }, "name": "t" } ], "body": { "type": "BlockStatement", "start": 526, "end": 705, "loc": { "start": { "line": 21, "column": 37 }, "end": { "line": 32, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 530, "end": 633, "loc": { "start": { "line": 22, "column": 2 }, "end": { "line": 27, "column": 4 } }, "declarations": [ { "type": "VariableDeclarator", "start": 536, "end": 632, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 27, "column": 3 } }, "id": { "type": "Identifier", "start": 536, "end": 541, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 13 }, "identifierName": "mocks" }, "name": "mocks" }, "init": { "type": "ObjectExpression", "start": 544, "end": 632, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 27, "column": 3 } }, "properties": [ { "type": "ObjectProperty", "start": 550, "end": 556, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 10 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 550, "end": 556, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 10 }, "identifierName": "config" }, "name": "config" }, "value": { "type": "Identifier", "start": 550, "end": 556, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 10 }, "identifierName": "config" }, "name": "config" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 562, "end": 574, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 16 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 562, "end": 574, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 16 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" }, "value": { "type": "Identifier", "start": 562, "end": 574, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 16 }, "identifierName": "MdSeedRunner" }, "name": "MdSeedRunner" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 580, "end": 589, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 13 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 580, "end": 589, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 13 }, "identifierName": "RunLogger" }, "name": "RunLogger" }, "value": { "type": "Identifier", "start": 580, "end": 589, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 13 }, "identifierName": "RunLogger" }, "name": "RunLogger" }, "extra": { "shorthand": true } }, { "type": "ObjectProperty", "start": 595, "end": 627, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 36 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 595, "end": 613, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 22 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" }, "value": { "type": "CallExpression", "start": 615, "end": 627, "loc": { "start": { "line": 26, "column": 24 }, "end": { "line": 26, "column": 36 } }, "callee": { "type": "MemberExpression", "start": 615, "end": 625, "loc": { "start": { "line": 26, "column": 24 }, "end": { "line": 26, "column": 34 } }, "object": { "type": "Identifier", "start": 615, "end": 620, "loc": { "start": { "line": 26, "column": 24 }, "end": { "line": 26, "column": 29 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 621, "end": 625, "loc": { "start": { "line": 26, "column": 30 }, "end": { "line": 26, "column": 34 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [] } } ] } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 637, "end": 659, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 29, "column": 24 } }, "expression": { "type": "AssignmentExpression", "start": 637, "end": 658, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 29, "co