How to append or prepend a value to a column in mongodb update
7th May, 2023
Click here to share
To append a column to another and update the value using MongoDB you can follow these steps if you are on MongoDB compass
Open the shell command panel on the base of the MongoDB window called
type use <collection>
where <collection> is the name of your database without the angle brackets
the the code below
db.collection.aggregate(
[
{ "$addFields": {
"name": { "$concat": [ "$firstName", " ", "$lastName" ] }
}},
{ "$out": <output collection name> }
]
)
UPDATE A COLUMN
SUBSCRIBE BELOW
To receive weekly newsletter from us signup below, we dont spam, and your information is secure with us
Leave a Reply
RELATED POSTS
Total of
0
Comment