> ## Documentation Index
> Fetch the complete documentation index at: https://docs-old.tilebox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CollectAs

```go theme={"system"}
func CollectAs[T proto.Message](seq iter.Seq2[[]byte, error]) ([]T, error)
```

Convert a sequence of bytes into a slice of `proto.Message`.

Useful to convert the output of [`Datapoints.Query`](https://docs-old.tilebox.com/api-reference/go/datasets/Datapoints.Query) into a slice of `proto.Message`.

This a convenience function for `Collect(As[T](seq))`.

## Parameters

**seq** `iter.Seq2[[]byte, error]`

The sequence of bytes to convert

## Returns

A slice of `proto.Message` or an error if any.

```go Go theme={"system"}
import (
  "time"
  datasets "github.com/tilebox/tilebox-go/datasets/v1"
	"github.com/tilebox/tilebox-go/query"
)

startDate := time.Date(2014, 10, 4, 0, 0, 0, 0, time.UTC) 
endDate := time.Date(2021, 2, 24, 0, 0, 0, 0, time.UTC) 
queryInterval := query.NewTimeInterval(startDate, endDate)

datapoints, err := datasets.CollectAs[*v1.Sentinel1Sar](
    client.Datapoints.Query(
      ctx,
      datasetID,
      datasets.WithCollectionIDs(collectionID),
      datasets.WithTemporalExtent(queryInterval),
    ),
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.