Go is in development for v1. Interested in contributing or chatting with us?Get in touch!
Go - Collection.Query.Stream()
Process query results as a stream.
import (
  "context"
  "fmt"
  "github.com/nitrictech/go-sdk/nitric"
)
func main() {
  profiles, err := nitric.NewCollection("profiles").With(nitric.CollectionReading)
  if err != nil {
    return
  }
  stream, err := profiles.Query().Stream(context.TODO())
  if err != nil {
    return
  }
  if err := nitric.Run(); err != nil {
    fmt.Println(err)
  }
}
Parameters
- Name
 ctx- Required
 - Required
 - Type
 - context
 - Description
 The context of the call, used for tracing.
Examples
Streaming results from a query
import (
  "context"
  "fmt"
  "github.com/nitrictech/go-sdk/nitric"
)
func main() {
  profiles, err := nitric.NewCollection("profiles").With(nitric.CollectionReading)
  if err != nil {
    return
  }
  stream, err := profiles.Query().Stream(context.TODO())
  if err != nil {
    return
  }
  for {
    res, err := stream.Next()
    if err != nil {
      fmt.Println("finished processing with: %w", err)
      break
    }
    fmt.Println(res.Content())
  }
  if err := nitric.Run(); err != nil {
    fmt.Println(err)
  }
}