New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version key missing when using bulkWrite insertOne method #13944
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
IslandRhythms
added
the
needs repro script
Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
label
Oct 6, 2023
|
vkarpov15
added
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
and removed
needs repro script
Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
labels
Oct 8, 2023
IslandRhythms
added
can't reproduce
Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Oct 10, 2023
Please modify the script below to demonstrate your issue. const mongoose = require('mongoose');
const { Schema } = mongoose;
const userSchema = new Schema({
fname: { type: String, required: true },
lname: { type: String },
city: { type: String },
});
const User = mongoose.model("User", userSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
await mongoose.connection.dropDatabase();
await User.create({
fname: 'test',
lname: 'testerson',
city: 'exam'
});
await User.create({
fname: 'John',
lname: 'Jacob',
city: 'Jingleheimerschmitz'
});
const data = await User.find();
const commandData = await data.map((item) => {
if (item._id) {
return { updateOne: {
filter: { _id: item._id },
update: item
}
}
} else {
return {
insertOne: {
document: item
}
}
}
});
console.log('what is command data', commandData);
await User.bulkWrite(commandData, { ordered: false });
const test = await User.find();
console.log('test', test);
}
run(); |
Hi @IslandRhythms Can you please take a look at the updated script.
|
IslandRhythms
added
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
can't reproduce
Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Oct 11, 2023
vkarpov15
added a commit
that referenced
this issue
Oct 16, 2023
vkarpov15
added a commit
that referenced
this issue
Oct 17, 2023
fix(model): add versionKey to bulkWrite when inserting or upserting
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
7.5.3
Node.js version
18.16.0
MongoDB server version
7.0.2
Typescript version (if applicable)
No response
Description
when using bulkWrite insertOne method version key is missing.
Steps to Reproduce
Hit POST api/user with body params and the version key is there with __v
Hit PATCH api/user/bulkWrite with body params
First document will be updated but in the newly created document version key is missing.
POST API Description
PATCH API description
Expected Behavior
version key should be available in the newly created document using bulkWrite insertOne method
The text was updated successfully, but these errors were encountered: