how to change column datatype
Hi Bhanu,
Could you elaborate the question with more information and an example ?
Is this from a mongo shell or using a specific MongoDB driver ? If so, which language ?
If you just would like to convert data types in MongoDB collection, you could try to use $convert aggregation pipeline operator (since MongoDB v4.0).
For example:
> db.collection.aggregate([{"$addFields":{"b":{"$convert":{"input":"$a", "to":"string"}}}}])
{
"_id": ObjectId("..."),
"a": NumberDecimal("1.01234567890123"),
"b": "1.01234567890123"
}
Regards,
Wan.