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}nitric.Run()}
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())}nitric.Run()}
See also
Last updated on Dec 19, 2024