Closed parth-007 closed 1 year ago
Describe the bug I have one collection and I want to populate it by using the migration script. I have one JSON, which I want to dump into collection using insertMany method
To Reproduce I have this model:
const SchoolSchema = new Schema( { name: { type: String, } }, { timestamps: { createdAt: "created_at", updatedAt: "updated_at", }, } ); module.exports = School = mongoose.model("schools", SchoolSchema);
I want to populate this table by one JSON object, which is like below
[ { name: "ABC" }, { name: "PQR" } ]
Here's the migration script:
const schoolsData = require("schools.json"); module.exports = { async up(db, client) { // For Population await db.collection('schools').insertMany(schoolsData); }, async down(db, client) { await db.collection('schools').drop(); } };
It does not add timestamps while adding the rows to the table.
Expected behavior Timestamps should be added
Additional context Please let me know If I am using this in a wrong way.
This issue seems to be related to Mongoose, not migrate-mongo. I'm closing this.
Describe the bug I have one collection and I want to populate it by using the migration script. I have one JSON, which I want to dump into collection using insertMany method
To Reproduce I have this model:
I want to populate this table by one JSON object, which is like below
Here's the migration script:
It does not add timestamps while adding the rows to the table.
Expected behavior Timestamps should be added
Additional context Please let me know If I am using this in a wrong way.