data engineering

몽고디비 모든 디비의 모든 컬렉션의 아이템 카운트를 가져오는 법.

qkqhxla1 2018. 6. 19. 16:05

https://stackoverflow.com/questions/39786228/how-to-get-total-number-of-records-across-all-databases-in-mongodb


let client = db.getMongo();
client.getDBNames().filter( name => name !== 'local')
    .map( elt => client.getDB(elt).stats().objects )
    .reduce( ( acc, cur ) => acc + cur, 0);