-
Does this library still maintained? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Yes it is, you can see new commits and releases on the repo. Do you have any issue? If so, please describe it throughtly. |
Beta Was this translation helpful? Give feedback.
-
Hey, yes I do have an issue. Just wanted to make sure I'm not putting effort describing the issue for nothing 😅
require("dotenv").config();
const { Seeder } = require("mongo-seeding");
const path = require("path");
const config = {
database: process.env.MONGO_URI,
dropDatabase: false,
};
const seeder = new Seeder(config);
const seed = seeder.readCollectionsFromPath(path.resolve("./seeds/tickets"), {
transformers: [Seeder.Transformers.replaceDocumentIdWithUnderscoreId],
});
seeder
.import(seed)
.then((_) => console.log("seeded successfully"))
.catch((err) => {
console.log(err);
console.log("error");
});
File structure is like so:
When I tried to run PS. in the end I managed to dig into the
require("dotenv").config();
const { Seeder } = require("mongo-seeding");
const fs = require("fs");
const config = {
database: process.env.MONGO_URI,
dropDatabase: false,
};
const seeder = new Seeder(config);
// const seed = seeder.readCollectionsFromPath(path.resolve("./seeds/tickets"), {
// transformers: [Seeder.Transformers.replaceDocumentIdWithUnderscoreId],
// });
const seed = fs.readFileSync("./tickets.json");
seeder
.import([JSON.parse(seed)])
.then((_) => console.log("seeded successfully!"))
.catch((err) => {
console.log(err);
console.log("error");
});
|
Beta Was this translation helpful? Give feedback.
-
From what I can see you have totally different content from what is described in the documentation here. You wrote: seeder.readCollectionsFromPath(path.resolve("./seeds/tickets"), ...) But in fact you should point to seeder.readCollectionsFromPath(path.resolve("./seeds"), ...) Collections are represented by directories. Also, the Closing it for now as it works as described in docs. If it won't work, please write a comment here and I can reopen it 🙂 However, please double check you followed the official guides first. Cheers! |
Beta Was this translation helpful? Give feedback.
From what I can see you have totally different content from what is described in the documentation here.
You wrote:
But in fact you should point to
./seeds
:Collections are represented by directories. Also, the
tickets.json
has invalid content. See the document I linked above to fix it.Closing it for now as it works as described in docs. If it won't work, please write a comment here and I can reopen it 🙂 However, please double check you followed the official guides first. Cheers!