-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Minimize does sometimes not working. Empty object is saved. #13782
Labels
backwards-breaking
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Comments
vkarpov15
added
the
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
label
Aug 25, 2023
IslandRhythms
added
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
and removed
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
labels
Aug 29, 2023
Checked in compass and an empty object is there const mongoose = require('mongoose');
async function run() {
await mongoose.connect('mongodb://localhost:27017/gh13782');
await mongoose.connection.dropDatabase();
const schema = new mongoose.Schema({
metadata: {
type: {},
default: {},
required: true,
_id: false
}
}, { minimize: true });
const Model = mongoose.model("Schema", schema);
const m = new Model({ metadata: {} });
await m.save();
console.log("Document has no metadata property")
const x = await Model.findById(m._id).exec();
x.metadata = {};
await x.save();
console.log(x.$isEmpty('metadata')) // true
console.log("Document now has empty metadata property");
console.log('what is x', x);
}
run(); |
vkarpov15
added a commit
that referenced
this issue
Sep 8, 2023
vkarpov15
added a commit
that referenced
this issue
Sep 26, 2023
vkarpov15
added a commit
that referenced
this issue
Sep 26, 2023
BREAKING CHANGE: apply minimize by default when updating document
vkarpov15
added
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
backwards-breaking
and removed
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
labels
Sep 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backwards-breaking
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Prerequisites
Mongoose version
7.4.4
Node.js version
16.20.2
MongoDB server version
7.0.0
Typescript version (if applicable)
No response
Description
Empty objects are sometimes deleted, sometimes not.
Steps to Reproduce
Expected Behavior
The saved document has the form
but it is
The text was updated successfully, but these errors were encountered: