I am having issues with projecting some fields with mongodb $project
my colection has the following datas
[{num:"SI-0101",mob:6289141515},...]
and my $project
query
[{
$project: {
"Id No.": "$num",
"Mobile No.": "$mob" // note on that ., i need it in o/p
}
}]
When I execute this, it raise error says Field path not ends with .
How I resolve this ?
2
Answers
MongoDb does not support keys that end with a dot (
.
). You can edit it in your code after the query. For example:You can use
$setField
to achieve such behaviour if you are using MongoDB v5.0+Mongo Playground