• 3/16

How to list all tables/collections in a database

The sess variable returned by Open satisfies the db.Database interface. If you’re working with a SQL database, sess will satisfy sqlbuilder.Database as well.

Use the Collection method (defined by db.Database) to get the names of all the collections in the database:

collections, err := sess.Collections()

log.Printf("Collections in %q: %v", sess.Name(), collections)
  • 3/16