UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,580 lines (1,579 loc) 483 kB
{ "type": "File", "start": 0, "end": 2403, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 91, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2403, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 91, "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": 92, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 40 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 61, "end": 70, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 18 } }, "imported": { "type": "Identifier", "start": 61, "end": 70, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 18 }, "identifierName": "ExitCodes" }, "name": "ExitCodes" }, "local": { "type": "Identifier", "start": 61, "end": 70, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 18 }, "identifierName": "ExitCodes" }, "name": "ExitCodes" } } ], "source": { "type": "StringLiteral", "start": 78, "end": 91, "loc": { "start": { "line": 4, "column": 26 }, "end": { "line": 4, "column": 39 } }, "extra": { "rawValue": "./constants", "raw": "'./constants'" }, "value": "./constants" } }, { "type": "ImportDeclaration", "start": 93, "end": 300, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 13, "column": 19 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 104, "end": 125, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 23 } }, "imported": { "type": "Identifier", "start": 104, "end": 125, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 23 }, "identifierName": "getFolderNameFromPath" }, "name": "getFolderNameFromPath" }, "local": { "type": "Identifier", "start": 104, "end": 125, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 23 }, "identifierName": "getFolderNameFromPath" }, "name": "getFolderNameFromPath" } }, { "type": "ImportSpecifier", "start": 129, "end": 154, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 27 } }, "imported": { "type": "Identifier", "start": 129, "end": 154, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 27 }, "identifierName": "getObjectWithSelectedKeys" }, "name": "getObjectWithSelectedKeys" }, "local": { "type": "Identifier", "start": 129, "end": 154, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 27 }, "identifierName": "getObjectWithSelectedKeys" }, "name": "getObjectWithSelectedKeys" } }, { "type": "ImportSpecifier", "start": 158, "end": 183, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 27 } }, "imported": { "type": "Identifier", "start": 158, "end": 183, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 27 }, "identifierName": "validateSeedersFolderName" }, "name": "validateSeedersFolderName" }, "local": { "type": "Identifier", "start": 158, "end": 183, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 27 }, "identifierName": "validateSeedersFolderName" }, "name": "validateSeedersFolderName" } }, { "type": "ImportSpecifier", "start": 187, "end": 213, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 28 } }, "imported": { "type": "Identifier", "start": 187, "end": 213, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 28 }, "identifierName": "validateSeederTemplatePath" }, "name": "validateSeederTemplatePath" }, "local": { "type": "Identifier", "start": 187, "end": 213, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 28 }, "identifierName": "validateSeederTemplatePath" }, "name": "validateSeederTemplatePath" } }, { "type": "ImportSpecifier", "start": 217, "end": 235, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 20 } }, "imported": { "type": "Identifier", "start": 217, "end": 235, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 20 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" }, "local": { "type": "Identifier", "start": 217, "end": 235, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 20 }, "identifierName": "validateUserConfig" }, "name": "validateUserConfig" } }, { "type": "ImportSpecifier", "start": 239, "end": 243, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 6 } }, "imported": { "type": "Identifier", "start": 239, "end": 243, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 6 }, "identifierName": "exit" }, "name": "exit" }, "local": { "type": "Identifier", "start": 239, "end": 243, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 6 }, "identifierName": "exit" }, "name": "exit" } }, { "type": "ImportSpecifier", "start": 247, "end": 279, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 34 } }, "imported": { "type": "Identifier", "start": 247, "end": 260, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 15 }, "identifierName": "__RewireAPI__" }, "name": "__RewireAPI__" }, "local": { "type": "Identifier", "start": 264, "end": 279, "loc": { "start": { "line": 12, "column": 19 }, "end": { "line": 12, "column": 34 }, "identifierName": "moduleRewireAPI" }, "name": "moduleRewireAPI" } } ], "source": { "type": "StringLiteral", "start": 288, "end": 299, "loc": { "start": { "line": 13, "column": 7 }, "end": { "line": 13, "column": 18 } }, "extra": { "rawValue": "./helpers", "raw": "'./helpers'" }, "value": "./helpers" } }, { "type": "ExpressionStatement", "start": 302, "end": 419, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 17, "column": 3 } }, "expression": { "type": "CallExpression", "start": 302, "end": 418, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 17, "column": 2 } }, "callee": { "type": "Identifier", "start": 302, "end": 306, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 4 }, "identifierName": "test" }, "name": "test" }, "arguments": [ { "type": "StringLiteral", "start": 307, "end": 341, "loc": { "start": { "line": 15, "column": 5 }, "end": { "line": 15, "column": 39 } }, "extra": { "rawValue": "should get folder name from path", "raw": "'should get folder name from path'" }, "value": "should get folder name from path" }, { "type": "ArrowFunctionExpression", "start": 343, "end": 417, "loc": { "start": { "line": 15, "column": 41 }, "end": { "line": 17, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 343, "end": 344, "loc": { "start": { "line": 15, "column": 41 }, "end": { "line": 15, "column": 42 }, "identifierName": "t" }, "name": "t" } ], "body": { "type": "BlockStatement", "start": 348, "end": 417, "loc": { "start": { "line": 15, "column": 46 }, "end": { "line": 17, "column": 1 } }, "body": [ { "type": "ExpressionStatement", "start": 352, "end": 415, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 65 } }, "expression": { "type": "CallExpression", "start": 352, "end": 414, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 64 } }, "callee": { "type": "MemberExpression", "start": 352, "end": 356, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 6 } }, "object": { "type": "Identifier", "start": 352, "end": 353, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 16, "column": 3 }, "identifierName": "t" }, "name": "t" }, "property": { "type": "Identifier", "start": 354, "end": 356, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 6 }, "identifierName": "is" }, "name": "is" }, "computed": false }, "arguments": [ { "type": "CallExpression", "start": 357, "end": 403, "loc": { "start": { "line": 16, "column": 7 }, "end": { "line": 16, "column": 53 } }, "callee": { "type": "Identifier", "start": 357, "end": 378, "loc": { "start": { "line": 16, "column": 7 }, "end": { "line": 16, "column": 28 }, "identifierName": "getFolderNameFromPath" }, "name": "getFolderNameFromPath" }, "arguments": [ { "type": "StringLiteral", "start": 379, "end": 402, "loc": { "start": { "line": 16, "column": 29 }, "end": { "line": 16, "column": 52 } }, "extra": { "rawValue": "some/path/with/folder", "raw": "'some/path/with/folder'" }, "value": "some/path/with/folder" } ] }, { "type": "StringLiteral", "start": 405, "end": 413, "loc": { "start": { "line": 16, "column": 55 }, "end": { "line": 16, "column": 63 } }, "extra": { "rawValue": "folder", "raw": "'folder'" }, "value": "folder" } ] } } ], "directives": [] } } ] } }, { "type": "ExpressionStatement", "start": 421, "end": 740, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 30, "column": 3 } }, "expression": { "type": "CallExpression", "start": 421, "end": 739, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 30, "column": 2 } }, "callee": { "type": "Identifier", "start": 421, "end": 425, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 4 }, "identifierName": "test" }, "name": "test" }, "arguments": [ { "type": "StringLiteral", "start": 426, "end": 476, "loc": { "start": { "line": 19, "column": 5 }, "end": { "line": 19, "column": 55 } }, "extra": { "rawValue": "should get similar object with the selected keys", "raw": "'should get similar object with the selected keys'" }, "value": "should get similar object with the selected keys" }, { "type": "ArrowFunctionExpression", "start": 478, "end": 738, "loc": { "start": { "line": 19, "column": 57 }, "end": { "line": 30, "column": 1 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 478, "end": 479, "loc": { "start": { "line": 19, "column": 57 }, "end": { "line": 19, "column": 58 }, "identifierName": "t" }, "name": "t" } ], "body": { "type": "BlockStatement", "start": 483, "end": 738, "loc": { "start": { "line": 19, "column": 62 }, "end": { "line": 30, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 487, "end": 551, "loc": { "start": { "line": 20, "column": 2 }, "end": { "line": 24, "column": 4 } }, "declarations": [ { "type": "VariableDeclarator", "start": 493, "end": 550, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 24, "column": 3 } }, "id": { "type": "Identifier", "start": 493, "end": 500, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 15 }, "identifierName": "testObj" }, "name": "testObj" }, "init": { "type": "ObjectExpression", "start": 503, "end": 550, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 24, "column": 3 } }, "properties": [ { "type": "ObjectProperty", "start": 509, "end": 517, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 12 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 509, "end": 513, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 8 }, "identifierName": "key1" }, "name": "key1" }, "value": { "type": "StringLiteral", "start": 515, "end": 517, "loc": { "start": { "line": 21, "column": 10 }, "end": { "line": 21, "column": 12 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } }, { "type": "ObjectProperty", "start": 523, "end": 531, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 12 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 523, "end": 527, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 8 }, "identifierName": "key2" }, "name": "key2" }, "value": { "type": "StringLiteral", "start": 529, "end": 531, "loc": { "start": { "line": 22, "column": 10 }, "end": { "line": 22, "column": 12 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } }, { "type": "ObjectProperty", "start": 537, "end": 545, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 12 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 537, "end": 541, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 8 }, "identifierName": "key3" }, "name": "key3" }, "value": { "type": "StringLiteral", "start": 543, "end": 545, "loc": { "start": { "line": 23, "column": 10 }, "end": { "line": 23, "column": 12 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 555, "end": 624, "loc": { "start": { "line": 26, "column": 2 }, "end": { "line": 26, "column": 71 } }, "declarations": [ { "type": "VariableDeclarator", "start": 561, "end": 623, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 70 } }, "id": { "type": "Identifier", "start": 561, "end": 568, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 15 }, "identifierName": "results" }, "name": "results" }, "init": { "type": "CallExpression", "start": 571, "end": 623, "loc": { "start": { "line": 26, "column": 18 }, "end": { "line": 26, "column": 70 } }, "callee": { "type": "Identifier", "start": 571, "end": 596, "loc": { "start": { "line": 26, "column": 18 }, "end": { "line": 26, "column": 43 }, "identifierName": "getObjectWithSelectedKeys" }, "name": "getObjectWithSelectedKeys" }, "arguments": [ { "type": "Identifier", "start": 597, "end": 604, "loc": { "start": { "line": 26, "column": 44 }, "end": { "line": 26, "column": 51 }, "identifierName": "testObj" }, "name": "testObj" }, { "type": "ArrayExpression", "start": 606, "end": 622, "loc": { "start": { "line": 26, "column": 53 }, "end": { "line": 26, "column": 69 } }, "elements": [ { "type": "StringLiteral", "start": 607, "end": 613, "loc": { "start": { "line": 26, "column": 54 }, "end": { "line": 26, "column": 60 } }, "extra": { "rawValue": "key1", "raw": "'key1'" }, "value": "key1" }, { "type": "StringLiteral", "start": 615, "end": 621, "loc": { "start": { "line": 26, "column": 62 }, "end": { "line": 26, "column": 68 } }, "extra": { "rawValue": "key3", "raw": "'key3'" }, "value": "key3" } ] } ] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 627, "end": 694, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 27, "column": 69 } }, "declarations": [ { "type": "VariableDeclarator", "start": 633, "end": 693, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 68 } }, "id": { "type": "Identifier", "start": 633, "end": 648, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 23 }, "identifierName": "expectedResults" }, "name": "expectedResults" }, "init": { "type": "ObjectExpression", "start": 651, "end": 693, "loc": { "start": { "line": 27, "column": 26 }, "end": { "line": 27, "column": 68 } }, "properties": [ { "type": "ObjectProperty", "start": 653, "end": 671, "loc": { "start": { "line": 27, "column": 28 }, "end": { "line": 27, "column": 46 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 653, "end": 657, "loc": { "start": { "line": 27, "column": 28 }, "end": { "line": 27, "column": 32 }, "identifierName": "key1" }, "name": "key1" }, "value": { "type": "MemberExpression", "start": 659, "end": 671, "loc": { "start": { "line": 27, "column": 34 }, "end": { "line": 27, "column": 46 } }, "object": { "type": "Identifier", "start": 659, "end": 666, "loc": { "start": { "line": 27, "column": 34 }, "end": { "line": 27, "column": 41 }, "identifierName": "testObj" }, "name": "testObj" }, "property": { "type": "Identifier", "start": 667, "end": 671, "loc": { "start": { "line": 27, "column": 42 }, "end": { "line": 27, "column": 46 }, "identifierName": "key1" }, "name": "key1" }, "computed": false } }, { "type": "ObjectProperty", "start": 673, "end": 691, "loc": { "start": { "line": 27, "column": 48 }, "end": {