-
Type:
Improvement
-
Resolution: Gone away
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Shell
-
None
-
Execution Team 2021-10-18
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Following this example, I created a time series collection.
When trying to update the immutable _id field, I am getting Namespace test.weather is a timeseries collection error:
myReplicaSet5:PRIMARY> db.weather.updateOne({_id: ObjectId("61598144efba71465c1ab286")}, {$set: { _id: ObjectId("61597c28efba71465c1a9999")}})
uncaught exception: WriteError({
"index" : 0,
"code" : 166,
"errmsg" : "Namespace test.weather is a timeseries collection",
"op" : {
"q" : {
"_id" : ObjectId("61598144efba71465c1ab286")
},
"u" : {
"$set" : {
"_id" : ObjectId("61597c28efba71465c1a9999")
}
},
"multi" : false,
"upsert" : false
}
}) :
WriteError({
"index" : 0,
"code" : 166,
"errmsg" : "Namespace test.weather is a timeseries collection",
"op" : {
"q" : {
"_id" : ObjectId("61598144efba71465c1ab286")
},
"u" : {
"$set" : {
"_id" : ObjectId("61597c28efba71465c1a9999")
}
},
"multi" : false,
"upsert" : false
}
})
The expected error should be the same as for any other collection type, for example, trying to update the _id field on a regular collection products:
myReplicaSet5:PRIMARY> db.products.updateOne({_id: ObjectId("61598144efba71465c1ab286")}, {$set: { _id: ObjectId("61597c28efba71465c1a9999")}})
WriteError({
"index" : 0,
"code" : 66,
"errmsg" : "Performing an update on the path '_id' would modify the immutable field '_id'",
"op" : {
"q" : {
"_id" : ObjectId("61598144efba71465c1ab286")
},
"u" : {
"$set" : {
"_id" : ObjectId("61597c28efba71465c1a9999")
}
},
"multi" : false,
"upsert" : false
}
}) :
WriteError({
"index" : 0,
"code" : 66,
"errmsg" : "Performing an update on the path '_id' would modify the immutable field '_id'",
"op" : {
"q" : {
"_id" : ObjectId("61598144efba71465c1ab286")
},
"u" : {
"$set" : {
"_id" : ObjectId("61597c28efba71465c1a9999")
}
},
"multi" : false,
"upsert" : false
}
})
There should be nothing special about the _id filed on a time series collection.