The Go SDK is currently in experimental status. If you would like to provide feedback, please reach out to us with your suggestions and comments on our Discord.
Note: You are viewing documentation for version v0 of Go. View the latest version.
Go - Collection.Doc.Collection()
Gets a reference to a child collection on a document.
import (
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
profiles, err := nitric.NewCollection("profiles").With(nitric.CollectionReading)
if err != nil {
return
}
drakesEnemiesCollection, err := profiles.Doc("Drake Mallard").Collection("enemies")
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}
Parameters
- Name
name
- Required
- Required
- Type
- string
- Description
The name of the child collection to reference
Notes
Document collection relationships can be at most 1 deep.
// ✔️ We can go this deep
drakesEnemiesCollection, err := profiles.Doc("Drake Mallard").Collection("enemies")
if err != nil {
fmt.Println(err)
return
}
// ❌ But not this deep
drakesEnemiesEnemiesCollection, err := drakesEnemiesCollection.Doc("Steel Beak").Collection("enemies")
if err != nil {
fmt.Println(err)
return
}