I’m completely new to MongoDB. I’m using the free tier of cloud mongodb service where I’ve imported some data. How would I go about modifying some data. All documents in the collection called ‘transactions’ have fields called: "Transaction Name" and "Transaction Type", "Account Number". I’d like to change them to TransactionName and TransactionType, etc. Additionally, the Account Number has value of type number. I’d like to change it to string (and convert the value from number to string). All documents in the collection have this value (ie. no nulls) and all of them are of type number.
I can connect to mongosh or use a node script.
Thank you
2
Answers
Simply use $rename. Should be something like this based on the mongo example:
Example here.
You can use update with aggregation pipeline
Mongo Playground