@@ -68,7 +68,7 @@ You can also find some examples in [integration tests](https://github.com/typese
6868 DefaultSortingField : pointer.String (" num_employees" ),
6969 }
7070
71- client.Collections ().Create (schema)
71+ client.Collections ().Create (context. Background (), schema)
7272```
7373
7474### Index a document
@@ -86,7 +86,7 @@ You can also find some examples in [integration tests](https://github.com/typese
8686 Country : " USA" ,
8787 }
8888
89- client.Collection (" companies" ).Documents ().Create (document)
89+ client.Collection (" companies" ).Documents ().Create (context. Background (), document)
9090```
9191
9292### Upserting a document
@@ -104,7 +104,7 @@ You can also find some examples in [integration tests](https://github.com/typese
104104 Country : " USA" ,
105105 }
106106
107- client.Collection (" companies" ).Documents ().Upsert (newDocument)
107+ client.Collection (" companies" ).Documents ().Upsert (context. Background (), newDocument)
108108```
109109
110110### Search a collection
@@ -117,7 +117,7 @@ You can also find some examples in [integration tests](https://github.com/typese
117117 SortBy : &([]string {" num_employees:desc" }),
118118 }
119119
120- client.Collection (" companies" ).Documents ().Search (searchParameters)
120+ client.Collection (" companies" ).Documents ().Search (context. Background (), searchParameters)
121121```
122122
123123for the supporting multiple ` QueryBy ` params, you can add ` , ` after each field
@@ -130,13 +130,13 @@ for the supporting multiple `QueryBy` params, you can add `,` after each field
130130 SortBy : &([]string {" num_employees:desc" }),
131131 }
132132
133- client.Collection (" companies" ).Documents ().Search (searchParameters)
133+ client.Collection (" companies" ).Documents ().Search (context. Background (), searchParameters)
134134```
135135
136136### Retrieve a document
137137
138138``` go
139- client.Collection (" companies" ).Document (" 123" ).Retrieve ()
139+ client.Collection (" companies" ).Document (" 123" ).Retrieve (context. Background () )
140140```
141141
142142### Update a document
@@ -150,32 +150,32 @@ client.Collection("companies").Document("123").Retrieve()
150150 NumEmployees : 5500 ,
151151 }
152152
153- client.Collection (" companies" ).Document (" 123" ).Update (document)
153+ client.Collection (" companies" ).Document (" 123" ).Update (context. Background (), document)
154154```
155155
156156### Delete an individual document
157157
158158``` go
159- client.Collection (" companies" ).Document (" 123" ).Delete ()
159+ client.Collection (" companies" ).Document (" 123" ).Delete (context. Background () )
160160```
161161
162162### Delete a bunch of documents
163163
164164``` go
165165filter := &api.DeleteDocumentsParams {FilterBy: " num_employees:>100" , BatchSize : 100 }
166- client.Collection (" companies" ).Documents ().Delete (filter)
166+ client.Collection (" companies" ).Documents ().Delete (context. Background (), filter)
167167```
168168
169169### Retrieve a collection
170170
171171``` go
172- client.Collection (" companies" ).Retrieve ()
172+ client.Collection (" companies" ).Retrieve (context. Background () )
173173```
174174
175175### Export documents from a collection
176176
177177``` go
178- client.Collection (" companies" ).Documents ().Export ()
178+ client.Collection (" companies" ).Documents ().Export (context. Background () )
179179```
180180
181181### Import documents into a collection
@@ -203,7 +203,7 @@ Import an array of documents:
203203 BatchSize : pointer.Int (40 ),
204204 }
205205
206- client.Collection (" companies" ).Documents ().Import (documents, params)
206+ client.Collection (" companies" ).Documents ().Import (context. Background (), documents, params)
207207```
208208
209209Import a JSONL file:
@@ -216,19 +216,19 @@ Import a JSONL file:
216216 importBody , err := os.Open (" documents.jsonl" )
217217 // defer close, error handling ...
218218
219- client.Collection (" companies" ).Documents ().ImportJsonl (importBody, params)
219+ client.Collection (" companies" ).Documents ().ImportJsonl (context. Background (), importBody, params)
220220```
221221
222222### List all collections
223223
224224``` go
225- client.Collections ().Retrieve ()
225+ client.Collections ().Retrieve (context. Background () )
226226```
227227
228228### Drop a collection
229229
230230``` go
231- client.Collection (" companies" ).Delete ()
231+ client.Collection (" companies" ).Delete (context. Background () )
232232```
233233
234234### Create an API Key
@@ -241,25 +241,25 @@ client.Collection("companies").Delete()
241241 ExpiresAt : time.Now ().AddDate (0 , 6 , 0 ).Unix (),
242242 }
243243
244- client.Keys ().Create (keySchema)
244+ client.Keys ().Create (context. Background (), keySchema)
245245```
246246
247247### Retrieve an API Key
248248
249249``` go
250- client.Key (1 ).Retrieve ()
250+ client.Key (1 ).Retrieve (context. Background () )
251251```
252252
253253### List all keys
254254
255255``` go
256- client.Keys ().Retrieve ()
256+ client.Keys ().Retrieve (context. Background () )
257257```
258258
259259### Delete API Key
260260
261261``` go
262- client.Key (1 ).Delete ()
262+ client.Key (1 ).Delete (context. Background () )
263263```
264264
265265### Create or update an override
@@ -287,19 +287,19 @@ client.Key(1).Delete()
287287 },
288288 }
289289
290- client.Collection (" companies" ).Overrides ().Upsert (" customize-apple" , override)
290+ client.Collection (" companies" ).Overrides ().Upsert (context. Background (), " customize-apple" , override)
291291```
292292
293293### List all overrides
294294
295295``` go
296- client.Collection (" companies" ).Overrides ().Retrieve ()
296+ client.Collection (" companies" ).Overrides ().Retrieve (context. Background () )
297297```
298298
299299### Delete an override
300300
301301``` go
302- client.Collection (" companies" ).Override (" customize-apple" ).Delete ()
302+ client.Collection (" companies" ).Override (" customize-apple" ).Delete (context. Background () )
303303```
304304
305305### Create or Update an alias
@@ -312,19 +312,19 @@ client.Collection("companies").Override("customize-apple").Delete()
312312### Retrieve an alias
313313
314314``` go
315- client.Alias (" companies" ).Retrieve ()
315+ client.Alias (" companies" ).Retrieve (context. Background () )
316316```
317317
318318### List all aliases
319319
320320``` go
321- client.Aliases ().Retrieve ()
321+ client.Aliases ().Retrieve (context. Background () )
322322```
323323
324324### Delete an alias
325325
326326``` go
327- client.Alias (" companies" ).Delete ()
327+ client.Alias (" companies" ).Delete (context. Background () )
328328```
329329
330330### Create or update a multi-way synonym
@@ -333,7 +333,7 @@ client.Alias("companies").Delete()
333333 synonym := &api.SearchSynonymSchema {
334334 Synonyms : []string {" blazer" , " coat" , " jacket" },
335335 }
336- client.Collection (" products" ).Synonyms ().Upsert (" coat-synonyms" , synonym)
336+ client.Collection (" products" ).Synonyms ().Upsert (context. Background (), " coat-synonyms" , synonym)
337337```
338338
339339### Create or update a one-way synonym
@@ -343,37 +343,37 @@ client.Alias("companies").Delete()
343343 Root : " blazer" ,
344344 Synonyms : []string {" blazer" , " coat" , " jacket" },
345345 }
346- client.Collection (" products" ).Synonyms ().Upsert (" coat-synonyms" , synonym)
346+ client.Collection (" products" ).Synonyms ().Upsert (context. Background (), " coat-synonyms" , synonym)
347347```
348348
349349### Retrieve a synonym
350350
351351``` go
352- client.Collection (" products" ).Synonym (" coat-synonyms" ).Retrieve ()
352+ client.Collection (" products" ).Synonym (" coat-synonyms" ).Retrieve (context. Background () )
353353```
354354
355355### List all synonyms
356356
357357``` go
358- client.Collection (" products" ).Synonyms ().Retrieve ()
358+ client.Collection (" products" ).Synonyms ().Retrieve (context. Background () )
359359```
360360
361361### Delete a synonym
362362
363363``` go
364- client.Collection (" products" ).Synonym (" coat-synonyms" ).Delete ()
364+ client.Collection (" products" ).Synonym (" coat-synonyms" ).Delete (context. Background () )
365365```
366366
367367### Create snapshot (for backups)
368368
369369``` go
370- client.Operations ().Snapshot (" /tmp/typesense-data-snapshot" )
370+ client.Operations ().Snapshot (context. Background (), " /tmp/typesense-data-snapshot" )
371371```
372372
373373### Re-elect Leader
374374
375375``` go
376- client.Operations ().Vote ()
376+ client.Operations ().Vote (context. Background () )
377377```
378378
379379## Contributing
0 commit comments