After importing data into mongo, fields that were supposed to be of type null ended up being strings "null", is there a command or query to replace all instances of that string with a null value?
I have something like this
TestModel.updateMany({ test: 'null' },{ $set: { test: null } })
But it throws this error
CastError: Cast to ObjectId failed for value "null" at path "test" for model "TestModel"
I tried it in other fields where they are all string and it works, but the field "test" can be an Objectid or a null
EDIT:
document:
const TestSchema = new Schema({
test: { type: Schema.Types.ObjectId}
});
module.exports = db.model('TestModel', TestSchema);