mongodb的命令 show collections能不能像mysql一樣 show tables like '%xxx%'這樣使用?我試了,怎么都不行
學(xué)習(xí)是最好的投資!
除了以上方法外,還可以用db.getCollectionInfos()
方法,它直接接受一個(gè)filter:
db.getCollectionInfos({name: /test/})
show collections好像不能用這樣。但是你可以通過(guò) db.getCollectionNames獲得個(gè)數(shù)組,以后用javascript的filter選擇collections:
db.getCollectionNames().filter(function(el) {return el.indexOf('xxx') !== -1})