How to get length of all tables at once

16 views
Skip to first unread message

Christophe HOARAU

unread,
Dec 13, 2018, 2:32:51 AM12/13/18
to RethinkDB
Hello,

I'm trying with a single request to get size of all my tables (thought the web interface). I've tried that with not success :
r.dbList()
   
.forEach(
   
function(dbName){
       
return r.db(dbName).tableList().forEach(
           
function(t){
           
    const data = {};
       
        data[dbName] = r.db(dbName).table(t).count();
       
        return [data];
           
}
       
)
   
}
)

Of course I could use this syntax for more advanced queries, but it's a starting point to be able to query on multiple tables at once.

Thanks

Geoff Plitt

unread,
Dec 13, 2018, 2:40:05 AM12/13/18
to reth...@googlegroups.com
r.tableList().map(x => ({table:x, count:r.table(x).count()}))

--
You received this message because you are subscribed to the Google Groups "RethinkDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rethinkdb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Christophe HOARAU

unread,
Dec 13, 2018, 2:54:55 AM12/13/18
to RethinkDB
Thanks but how can I do the same for all databases ?

Geoff Plitt

unread,
Dec 13, 2018, 2:59:15 AM12/13/18
to reth...@googlegroups.com
r.dbList().filter(x => x.eq('rethinkdb').not()).map(db => ({db, listing:r.db(db).tableList().map(t => ({table:t, count:r.table(t).count()}))}))

On Wed, Dec 12, 2018 at 11:54 PM Christophe HOARAU <hoar...@gmail.com> wrote:
Thanks but how can I do the same for all databases ?

--
You received this message because you are subscribed to the Google Groups "RethinkDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rethinkdb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christophe HOARAU

unread,
Dec 13, 2018, 3:05:08 AM12/13/18
to RethinkDB
Thanks a lot, I managed to get the result I wanted thanks to your help.

Have a nice day
Reply all
Reply to author
Forward
0 new messages