• 4/16

Create a Table/Collection Reference

Use Collection (also defined by db.Database) to get a database structure in particular:

col := sess.Collection("books")

A collection reference satisfies db.Collection.

There are different methods you can call on the reference, like Name and Exists, which are handy for knowing whether a collection exists or not:

log.Println("Collection:", col.Name(), "Exists?:", col.Exists())
  • 4/16