UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,464 lines (1,463 loc) 1.16 MB
{ "type": "File", "start": 0, "end": 5727, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 224, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 5727, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 224, "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": 75, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 58, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 11 } }, "local": { "type": "Identifier", "start": 58, "end": 62, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 11 }, "identifierName": "path" }, "name": "path" } } ], "source": { "type": "StringLiteral", "start": 68, "end": 74, "loc": { "start": { "line": 3, "column": 17 }, "end": { "line": 3, "column": 23 } }, "extra": { "rawValue": "path", "raw": "'path'" }, "value": "path" } }, { "type": "ImportDeclaration", "start": 77, "end": 167, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 7, "column": 28 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 84, "end": 99, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 22 } }, "local": { "type": "Identifier", "start": 84, "end": 99, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 22 }, "identifierName": "SeederGenerator" }, "name": "SeederGenerator" } }, { "type": "ImportSpecifier", "start": 105, "end": 137, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 34 } }, "imported": { "type": "Identifier", "start": 105, "end": 118, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 15 }, "identifierName": "__RewireAPI__" }, "name": "__RewireAPI__" }, "local": { "type": "Identifier", "start": 122, "end": 137, "loc": { "start": { "line": 6, "column": 19 }, "end": { "line": 6, "column": 34 }, "identifierName": "moduleRewireAPI" }, "name": "moduleRewireAPI" } } ], "source": { "type": "StringLiteral", "start": 146, "end": 166, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 27 } }, "extra": { "rawValue": "./seeder-generator", "raw": "'./seeder-generator'" }, "value": "./seeder-generator" } }, { "type": "VariableDeclaration", "start": 169, "end": 529, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 18, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 175, "end": 528, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 18, "column": 1 } }, "id": { "type": "Identifier", "start": 175, "end": 185, "loc": { "start": { "line": 9, "column": 6 }, "end": { "line": 9, "column": 16 }, "identifierName": "helperData" }, "name": "helperData" }, "init": { "type": "ObjectExpression", "start": 188, "end": 528, "loc": { "start": { "line": 9, "column": 19 }, "end": { "line": 18, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 192, "end": 209, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 19 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 192, "end": 196, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 6 }, "identifierName": "name" }, "name": "name" }, "value": { "type": "StringLiteral", "start": 198, "end": 209, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 19 } }, "extra": { "rawValue": "some-name", "raw": "'some-name'" }, "value": "some-name" } }, { "type": "ObjectProperty", "start": 213, "end": 235, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 24 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 213, "end": 223, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 12 }, "identifierName": "seederName" }, "name": "seederName" }, "value": { "type": "StringLiteral", "start": 225, "end": 235, "loc": { "start": { "line": 11, "column": 14 }, "end": { "line": 11, "column": 24 } }, "extra": { "rawValue": "SomeName", "raw": "'SomeName'" }, "value": "SomeName" } }, { "type": "ObjectProperty", "start": 239, "end": 276, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 39 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 239, "end": 253, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 16 }, "identifierName": "seederFileName" }, "name": "seederFileName" }, "value": { "type": "StringLiteral", "start": 255, "end": 276, "loc": { "start": { "line": 12, "column": 18 }, "end": { "line": 12, "column": 39 } }, "extra": { "rawValue": "some-name.seeder.js", "raw": "'some-name.seeder.js'" }, "value": "some-name.seeder.js" } }, { "type": "ObjectProperty", "start": 280, "end": 327, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 49 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 280, "end": 294, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 16 }, "identifierName": "seederFilePath" }, "name": "seederFilePath" }, "value": { "type": "StringLiteral", "start": 296, "end": 327, "loc": { "start": { "line": 13, "column": 18 }, "end": { "line": 13, "column": 49 } }, "extra": { "rawValue": "some/path/some-name.seeder.js", "raw": "'some/path/some-name.seeder.js'" }, "value": "some/path/some-name.seeder.js" } }, { "type": "ObjectProperty", "start": 331, "end": 395, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 66 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 331, "end": 353, "loc": { "start": { "line": 14, "column": 2 }, "end": { "line": 14, "column": 24 }, "identifierName": "seederFileRelativePath" }, "name": "seederFileRelativePath" }, "value": { "type": "StringLiteral", "start": 355, "end": 395, "loc": { "start": { "line": 14, "column": 26 }, "end": { "line": 14, "column": 66 } }, "extra": { "rawValue": "some/relative-path/some-name.seeder.js", "raw": "'some/relative-path/some-name.seeder.js'" }, "value": "some/relative-path/some-name.seeder.js" } }, { "type": "ObjectProperty", "start": 399, "end": 430, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 33 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 399, "end": 413, "loc": { "start": { "line": 15, "column": 2 }, "end": { "line": 15, "column": 16 }, "identifierName": "seederTemplate" }, "name": "seederTemplate" }, "value": { "type": "StringLiteral", "start": 415, "end": 430, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 15, "column": 33 } }, "extra": { "rawValue": "some template", "raw": "'some template'" }, "value": "some template" } }, { "type": "ObjectProperty", "start": 434, "end": 480, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 48 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 434, "end": 455, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 23 }, "identifierName": "userSeedersFolderPath" }, "name": "userSeedersFolderPath" }, "value": { "type": "StringLiteral", "start": 457, "end": 480, "loc": { "start": { "line": 16, "column": 25 }, "end": { "line": 16, "column": 48 } }, "extra": { "rawValue": "some/path/for/seeders", "raw": "'some/path/for/seeders'" }, "value": "some/path/for/seeders" } }, { "type": "ObjectProperty", "start": 484, "end": 525, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 43 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 484, "end": 505, "loc": { "start": { "line": 17, "column": 2 }, "end": { "line": 17, "column": 23 }, "identifierName": "userSeedersFolderName" }, "name": "userSeedersFolderName" }, "value": { "type": "StringLiteral", "start": 507, "end": 525, "loc": { "start": { "line": 17, "column": 25 }, "end": { "line": 17, "column": 43 } }, "extra": { "rawValue": "some-folder-name", "raw": "'some-folder-name'" }, "value": "some-folder-name" } } ] } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 531, "end": 1412, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 52, "column": 3 } }, "expression": { "type": "CallExpression", "start": 531, "end": 1411, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 52, "column": 2 } }, "callee": { "type": "Identifier", "start": 531, "end": 535, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 20, "column": 4 }, "identifierName": "test" }, "name": "test" }, "arguments": [ { "type": "StringLiteral", "start": 536, "end": 585, "loc": { "start": { "line": 20, "column": 5 }, "end": { "line": 20, "column": 54 } }, "extra": { "rawValue": "should create a new instance of SeederGenerator", "raw": "'should create a new instance of SeederGenerator'" }, "value": "should create a new instance of SeederGenerator" }, { "type": "ArrowFunctionExpression", "start": 587, "end": 1410, "loc": { "start": { "line": 20, "column": 56 }, "end": { "line": 52, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 587, "end": 588, "loc": { "start": { "line": 20, "column": 56 }, "end": { "line": 20, "column": 57 }, "identifierName": "t" }, "name": "t" } ], "body": { "type": "BlockStatement", "start": 592, "end": 1410, "loc": { "start": { "line": 20, "column": 61 }, "end": { "line": 52, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 596, "end": 800, "loc": { "start": { "line": 21, "column": 2 }, "end": { "line": 25, "column": 4 } }, "declarations": [ { "type": "VariableDeclarator", "start": 602, "end": 799, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 25, "column": 3 } }, "id": { "type": "Identifier", "start": 602, "end": 613, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 19 }, "identifierName": "createStubs" }, "name": "createStubs" }, "init": { "type": "ArrowFunctionExpression", "start": 616, "end": 799, "loc": { "start": { "line": 21, "column": 22 }, "end": { "line": 25, "column": 3 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 622, "end": 799, "loc": { "start": { "line": 21, "column": 28 }, "end": { "line": 25, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 628, "end": 682, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 58 } }, "expression": { "type": "CallExpression", "start": 628, "end": 681, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 57 } }, "callee": { "type": "MemberExpression", "start": 628, "end": 638, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 14 } }, "object": { "type": "Identifier", "start": 628, "end": 633, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 9 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 634, "end": 638, "loc": { "start": { "line": 22, "column": 10 }, "end": { "line": 22, "column": 14 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [ { "type": "MemberExpression", "start": 639, "end": 664, "loc": { "start": { "line": 22, "column": 15 }, "end": { "line": 22, "column": 40 } }, "object": { "type": "Identifier", "start": 639, "end": 654, "loc": { "start": { "line": 22, "column": 15 }, "end": { "line": 22, "column": 30 }, "identifierName": "SeederGenerator" }, "name": "SeederGenerator" }, "property": { "type": "Identifier", "start": 655, "end": 664, "loc": { "start": { "line": 22, "column": 31 }, "end": { "line": 22, "column": 40 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false }, { "type": "StringLiteral", "start": 666, "end": 680, "loc": { "start": { "line": 22, "column": 42 }, "end": { "line": 22, "column": 56 } }, "extra": { "rawValue": "_initOptions", "raw": "'_initOptions'" }, "value": "_initOptions" } ] } }, { "type": "ExpressionStatement", "start": 687, "end": 739, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 56 } }, "expression": { "type": "CallExpression", "start": 687, "end": 738, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 55 } }, "callee": { "type": "MemberExpression", "start": 687, "end": 697, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 14 } }, "object": { "type": "Identifier", "start": 687, "end": 692, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 9 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 693, "end": 697, "loc": { "start": { "line": 23, "column": 10 }, "end": { "line": 23, "column": 14 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [ { "type": "MemberExpression", "start": 698, "end": 723, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 40 } }, "object": { "type": "Identifier", "start": 698, "end": 713, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 30 }, "identifierName": "SeederGenerator" }, "name": "SeederGenerator" }, "property": { "type": "Identifier", "start": 714, "end": 723, "loc": { "start": { "line": 23, "column": 31 }, "end": { "line": 23, "column": 40 }, "identifierName": "prototype" }, "name": "prototype" }, "computed": false }, { "type": "StringLiteral", "start": 725, "end": 737, "loc": { "start": { "line": 23, "column": 42 }, "end": { "line": 23, "column": 54 } }, "extra": { "rawValue": "_initMemFs", "raw": "'_initMemFs'" }, "value": "_initMemFs" } ] } }, { "type": "ExpressionStatement", "start": 744, "end": 795, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 55 } }, "expression": { "type": "CallExpression", "start": 744, "end": 794, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 54 } }, "callee": { "type": "MemberExpression", "start": 744, "end": 754, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 14 } }, "object": { "type": "Identifier", "start": 744, "end": 749, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 9 }, "identifierName": "sinon" }, "name": "sinon" }, "property": { "type": "Identifier", "start": 750, "end": 754, "loc": { "start": { "line": 24, "column": 10 }, "end": { "line": 24, "column": 14 }, "identifierName": "stub" }, "name": "stub" }, "computed": false }, "arguments": [ { "type": "MemberExpression", "start": 755, "end": 780, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 24, "column": 40 } }, "object": { "type": "Identifier", "start": 755, "end": 770, "loc": { "start": {