Looks like a great library, however I couldn't get either of the methods to import the example data to work. Am I doing something incorrectly?
/tmp $ git clone https://github.com/pkosiec/mongo-seeding
Cloning into 'mongo-seeding'...
remote: Counting objects: 838, done.
remote: Compressing objects: 100% (92/92), done.
remote: Total 838 (delta 63), reused 73 (delta 34), pack-reused 708
Receiving objects: 100% (838/838), 556.96 KiB | 87.00 KiB/s, done.
Resolving deltas: 100% (485/485), done.
/tmp $ cd mongo-seeding-test
/tmp/mongo-seeding-test $ cat package.json index.js
{
"name": "mongo-seeding-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"mongo-seeding": "^2.2.0"
}
}
const { seedDatabase } = require('mongo-seeding');
const path = require('path');
const config = {
database: {
host: '127.0.0.1',
port: 27017,
name: 'mydatabase',
},
inputPath: path.resolve(__dirname, '../mongo-seeding/samples/example/data'),
dropDatabase: true,
};
(async () => {
try {
await seedDatabase(config);
} catch (err) {
// Handle errors
console.error('there was an error:');
console.error(err);
}
// Do whatever you want after successful import
})()
/tmp/mongo-seeding-test $ node index.js
there was an error:
{ MongoSeedingError: Error: Cannot find module 'mongodb'
at wrapError (/private/tmp/mongo-seeding-test/node_modules/mongo-seeding/dist/index.js:52:19)
at Object.<anonymous> (/private/tmp/mongo-seeding-test/node_modules/mongo-seeding/dist/index.js:44:15)
at Generator.next (<anonymous>)
at /private/tmp/mongo-seeding-test/node_modules/mongo-seeding/dist/index.js:7:71
at new Promise (<anonymous>)
at __awaiter (/private/tmp/mongo-seeding-test/node_modules/mongo-seeding/dist/index.js:3:12)
at exports.seedDatabase (/private/tmp/mongo-seeding-test/node_modules/mongo-seeding/dist/index.js:14:43)
at __dirname (/private/tmp/mongo-seeding-test/index.js:17:11)
at Object.<anonymous> (/private/tmp/mongo-seeding-test/index.js:24:3)
at Module._compile (module.js:660:30) name: 'MongoSeedingError' }
/tmp/mongo-seeding-test $ cd ..
/tmp $ cd mongo-seeding
/tmp/mongo-seeding $ cd samples/example/data/
/tmp/mongo-seeding/samples/example/data $ seed -u 'mongodb://127.0.0.1:27017/mydb' -d .
mongo-seeding Starting... +0ms
mongo-seeding Closing connection... +5ms
Error MongoSeedingError: Error: Cannot find module 'mongodb'