mongodb的命令 show collections能不能像mysql一樣 show tables like '%xxx%'這樣使用?我試了,怎么都不行
2 回答

肥皂起泡泡
TA貢獻1829條經驗 獲得超6個贊
show collections好像不能用這樣。但是你可以通過 db.getCollectionNames獲得個數組,以后用javascript的filter選擇collections:
db.getCollectionNames().filter(function(el) {return el.indexOf('xxx') !== -1})

Qyouu
TA貢獻1786條經驗 獲得超11個贊
除了以上方法外,還可以用db.getCollectionInfos()
方法,它直接接受一個filter:
db.getCollectionInfos({name: /test/})
- 2 回答
- 0 關注
- 4167 瀏覽
添加回答
舉報
0/150
提交
取消