Skip to content

Commit 0bfdbc5

Browse files
committed
Document typed client.
1 parent 17bdfa8 commit 0bfdbc5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ You can also find some examples in [integration tests](https://github.com/typese
7171
client.Collections().Create(context.Background(), schema)
7272
```
7373

74+
### Typed document operations
75+
76+
In `v2.0.0`+, the client allows you to define a document struct to be used type for some of the document operations.
77+
78+
To do that, you've to use `typesense.GenericCollection`:
79+
80+
```go
81+
type companyDocument struct {
82+
ID string `json:"id"`
83+
CompanyName string `json:"company_name"`
84+
NumEmployees int `json:"num_employees"`
85+
Country string `json:"country"`
86+
}
87+
88+
// doc is a typed document
89+
doc, err := typesense.GenericCollection[*companyDocument](typesenseClient, collectionName).Document("123").Retrieve(context.Background())
90+
```
91+
7492
### Index a document
7593

7694
```go

0 commit comments

Comments
 (0)