List All Tables/Collections in a Database
Open returns a
sessvariable (which satisfies the db.Database
interface), use the
Collections method to get all the structures in the
collections, err := sess.Collections() ... log.Printf("Collections in %q: %v", sess.Name(), collections)
db.Databaseinterface provides methods that work on both SQL and NoSQL databases. In light of this, the structures of both database types are referred to generally as ‘collections’ and no particular distinction is made between ‘tables’ and ‘collections’.
You can call different
db.Databasemethods depending on the database type. For example, if you’re working with a SQL database,
sesswill also satisfy sqlbuilder.Database.