I am trying to update some NumberLong type value in one of my collection with some other NumberLong value. Below is my collection structure :
{
"_id" : ObjectId("55e57337d4c6cf80e68b1fe3"),
"tenantId" : NumberLong(7),
"refId" : NumberLong(20),
"refIdentifierName" : "resourceInstanceId",
"config" : {
"contract" : {
"contractLength" : "12 months",
"startDate" : "2015-01-21T09:36:39+00:00",
"billingFrequency" : "monthly",
"margin" : 9,
"endDate" : "2016-01-21T09:36:39+00:00"
}
}
Lets say here i am trying to update all tenantId with value 7 to 8.
This is the script i am using :
var cursor = db.resourceInstanceConfiguration.find();
while (cursor.hasNext()) {
var x = cursor.next();
x['tenantId'] = x['tenantId'].replace('7','8');
db.resourceInstanceConfiguration.update({_id : x._id}, x);
}
Getting error : TypeError: Object NumberLong(6) has no method 'replace'