我的收藏看起来像这样:
[
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": "This is title one"
},
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": null
},
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": "This is title three"
}
]
但是我想把所有null的标题转换成string(not-found):
[
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": "This is title one"
},
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": "not-found" // null to be converted to string
},
{
"_id": {
"$oid": "638ecf5247cf747bdd862bfb"
},
"title": "This is title three"
}
]
如何将所有具有空标题的文档的空标题转换为字符串?
2条答案
按热度按时间b1zrtrql1#
您可以使用简单的更新:
了解它在playground example上的工作原理
ki0zmccv2#
三件事:
{title:null}
的项目Playground-https://mongoplayground.net/p/DfAWE1Swszb