How to concat numeric and string value in mongodb?
You can use $toString
from mongo 4.0 version.
db.getCollection('table_name').aggregate([ {"$project":{ "columnName":{ "$concat":[ {"$toString":{"$arrayElemAt":["$key.firstArray",0]}}, "hello world" ] } }}])
You can try below query to $concat
long and string value. Use $substr
to convert the computed long value to string.
db.getCollection('table_name').aggregate([ {"$project":{ "columnName":{ "$concat":[ {"$substr":[{"$arrayElemAt":["$key.firstArray",0]},0,-1]}, "hello world" ] } }}])