gpt4 book ai didi

MongoDB 外壳 : how to search for collections which match a name or regex

转载 作者:IT老高 更新时间:2023-10-28 13:24:45 27 4
gpt4 key购买 nike

当我使用显示集合时,它会返回一个很长的所有集合的列表,我如何编写查询来返回与模式匹配的集合。我希望得到类似 db.collections({name:/pattern/}) 但找不到

最佳答案

您可以使用 db.getCollectionNames()Array.filter() :

db.getCollectionNames().filter(function (collection) { return /pattern/.test(collection) })

关于MongoDB 外壳 : how to search for collections which match a name or regex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26684307/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com