chub-dev 0.1.0 → 0.1.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +55 -0
  2. package/bin/chub-mcp +2 -0
  3. package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
  4. package/dist/airtable/docs/database/python/DOC.md +1735 -0
  5. package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
  6. package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
  7. package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
  8. package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
  9. package/dist/asana/docs/tasks/DOC.md +1396 -0
  10. package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
  11. package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
  12. package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
  13. package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
  14. package/dist/auth0/docs/identity/python/DOC.md +1199 -0
  15. package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
  16. package/dist/aws/docs/s3/python/DOC.md +1807 -0
  17. package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
  18. package/dist/binance/docs/trading/python/DOC.md +1454 -0
  19. package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
  20. package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
  21. package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
  22. package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
  23. package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
  24. package/dist/clerk/docs/auth/python/DOC.md +274 -0
  25. package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
  26. package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
  27. package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
  28. package/dist/cohere/docs/llm/DOC.md +1335 -0
  29. package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
  30. package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
  31. package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
  32. package/dist/deepgram/docs/speech/python/DOC.md +685 -0
  33. package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
  34. package/dist/deepl/docs/translation/python/DOC.md +944 -0
  35. package/dist/deepseek/docs/llm/DOC.md +1220 -0
  36. package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
  37. package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
  38. package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
  39. package/dist/discord/docs/bot/python/DOC.md +1130 -0
  40. package/dist/elasticsearch/docs/search/DOC.md +1634 -0
  41. package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
  42. package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
  43. package/dist/firebase/docs/auth/DOC.md +1015 -0
  44. package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
  45. package/dist/gemini/docs/genai/python/DOC.md +555 -0
  46. package/dist/github/docs/octokit/DOC.md +1560 -0
  47. package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
  48. package/dist/google/docs/bigquery/python/DOC.md +1503 -0
  49. package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
  50. package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
  51. package/dist/huggingface/docs/transformers/DOC.md +948 -0
  52. package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
  53. package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
  54. package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
  55. package/dist/jira/docs/issues/python/DOC.md +1492 -0
  56. package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
  57. package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
  58. package/dist/landingai-ade/docs/api/DOC.md +620 -0
  59. package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
  60. package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
  61. package/dist/landingai-ade/skills/SKILL.md +489 -0
  62. package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
  63. package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
  64. package/dist/linear/docs/tracker/DOC.md +1554 -0
  65. package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
  66. package/dist/livekit/docs/realtime/python/DOC.md +163 -0
  67. package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
  68. package/dist/meilisearch/docs/search/DOC.md +1241 -0
  69. package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
  70. package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
  71. package/dist/mongodb/docs/atlas/DOC.md +2041 -0
  72. package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
  73. package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
  74. package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
  75. package/dist/okta/docs/identity/python/DOC.md +1401 -0
  76. package/dist/openai/docs/chat/javascript/DOC.md +407 -0
  77. package/dist/openai/docs/chat/python/DOC.md +568 -0
  78. package/dist/paypal/docs/checkout/DOC.md +278 -0
  79. package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
  80. package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
  81. package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
  82. package/dist/plaid/docs/banking/python/DOC.md +1203 -0
  83. package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
  84. package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
  85. package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
  86. package/dist/prisma/docs/orm/python/DOC.md +1317 -0
  87. package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
  88. package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
  89. package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
  90. package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
  91. package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
  92. package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
  93. package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
  94. package/dist/redis/docs/key-value/python/DOC.md +2054 -0
  95. package/dist/registry.json +2817 -0
  96. package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
  97. package/dist/resend/docs/email/DOC.md +1271 -0
  98. package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
  99. package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
  100. package/dist/search-index.json +1 -0
  101. package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
  102. package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
  103. package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
  104. package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
  105. package/dist/shopify/docs/storefront/DOC.md +457 -0
  106. package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
  107. package/dist/slack/docs/workspace/python/DOC.md +271 -0
  108. package/dist/square/docs/payments/javascript/DOC.md +1855 -0
  109. package/dist/square/docs/payments/python/DOC.md +1728 -0
  110. package/dist/stripe/docs/api/DOC.md +1727 -0
  111. package/dist/stripe/docs/payments/DOC.md +1726 -0
  112. package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
  113. package/dist/stytch/docs/auth/python/DOC.md +1962 -0
  114. package/dist/supabase/docs/client/DOC.md +1606 -0
  115. package/dist/twilio/docs/messaging/python/DOC.md +469 -0
  116. package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
  117. package/dist/vercel/docs/platform/DOC.md +1940 -0
  118. package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
  119. package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
  120. package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
  121. package/dist/zendesk/docs/support/python/DOC.md +2297 -0
  122. package/package.json +22 -6
  123. package/skills/get-api-docs/SKILL.md +84 -0
  124. package/src/commands/annotate.js +83 -0
  125. package/src/commands/build.js +12 -1
  126. package/src/commands/feedback.js +150 -0
  127. package/src/commands/get.js +83 -42
  128. package/src/commands/search.js +7 -0
  129. package/src/index.js +43 -17
  130. package/src/lib/analytics.js +90 -0
  131. package/src/lib/annotations.js +57 -0
  132. package/src/lib/bm25.js +170 -0
  133. package/src/lib/cache.js +69 -6
  134. package/src/lib/config.js +8 -3
  135. package/src/lib/identity.js +99 -0
  136. package/src/lib/registry.js +103 -20
  137. package/src/lib/telemetry.js +86 -0
  138. package/src/mcp/server.js +177 -0
  139. package/src/mcp/tools.js +251 -0
@@ -0,0 +1,1268 @@
1
+ ---
2
+ name: vector-db
3
+ description: "Weaviate TypeScript/JavaScript SDK (v3) for vector database operations and semantic search"
4
+ metadata:
5
+ languages: "javascript"
6
+ versions: "3.9.0"
7
+ updated-on: "2026-03-02"
8
+ source: maintainer
9
+ tags: "weaviate,vector-db,search,embeddings,ai"
10
+ ---
11
+
12
+ # Weaviate TypeScript/JavaScript SDK (v3)
13
+
14
+ ## Golden Rule
15
+
16
+ **ALWAYS use the official `weaviate-client` package (v3.x).**
17
+
18
+ ```bash
19
+ npm install weaviate-client
20
+ ```
21
+
22
+ **NEVER use:**
23
+ - `weaviate-ts-client` (deprecated)
24
+ - The v2 client (deprecated as of 2024)
25
+ - Unofficial or outdated packages
26
+
27
+ The v3 client uses gRPC for 60-80% faster performance, first-class TypeScript support, and modern ES Modules.
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ ### Install the Client
34
+
35
+ ```bash
36
+ npm install weaviate-client
37
+ ```
38
+
39
+ ### Environment Variables
40
+
41
+ Create a `.env` file:
42
+
43
+ ```env
44
+ WEAVIATE_URL=https://your-instance.weaviate.network
45
+ WEAVIATE_API_KEY=your-api-key-here
46
+ OPENAI_API_KEY=your-openai-key-here
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Initialization
52
+
53
+ ### Connect to Weaviate Cloud
54
+
55
+ ```typescript
56
+ import weaviate, { WeaviateClient } from 'weaviate-client';
57
+
58
+ const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
59
+ process.env.WEAVIATE_URL!,
60
+ {
61
+ authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY!),
62
+ headers: {
63
+ 'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY!,
64
+ }
65
+ }
66
+ );
67
+
68
+ console.log('Connected to Weaviate');
69
+ ```
70
+
71
+ ### Connect to Local Instance
72
+
73
+ ```typescript
74
+ import weaviate from 'weaviate-client';
75
+
76
+ const client = await weaviate.connectToLocal({
77
+ host: 'localhost',
78
+ port: 8080,
79
+ grpcPort: 50051,
80
+ headers: {
81
+ 'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY!,
82
+ }
83
+ });
84
+ ```
85
+
86
+ ### Custom Connection
87
+
88
+ ```typescript
89
+ import weaviate from 'weaviate-client';
90
+
91
+ const client = await weaviate.connectToCustom({
92
+ httpHost: 'weaviate.example.com',
93
+ httpPort: 443,
94
+ httpSecure: true,
95
+ grpcHost: 'grpc.weaviate.example.com',
96
+ grpcPort: 443,
97
+ grpcSecure: true,
98
+ authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY!),
99
+ headers: {
100
+ 'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY!,
101
+ }
102
+ });
103
+ ```
104
+
105
+ ### Close Connection
106
+
107
+ ```typescript
108
+ await client.close();
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Collections
114
+
115
+ ### Create a Collection
116
+
117
+ #### Basic Collection
118
+
119
+ ```typescript
120
+ import { dataType } from 'weaviate-client';
121
+
122
+ await client.collections.create({
123
+ name: 'Article',
124
+ properties: [
125
+ { name: 'title', dataType: dataType.TEXT },
126
+ { name: 'body', dataType: dataType.TEXT },
127
+ { name: 'author', dataType: dataType.TEXT },
128
+ { name: 'publishDate', dataType: dataType.DATE },
129
+ { name: 'viewCount', dataType: dataType.INT },
130
+ ],
131
+ });
132
+ ```
133
+
134
+ #### Collection with Vectorizer
135
+
136
+ ```typescript
137
+ import { configure, dataType } from 'weaviate-client';
138
+
139
+ await client.collections.create({
140
+ name: 'Article',
141
+ vectorizers: configure.vectorizer.text2VecOpenAI({
142
+ model: 'text-embedding-3-small',
143
+ }),
144
+ properties: [
145
+ { name: 'title', dataType: dataType.TEXT },
146
+ { name: 'body', dataType: dataType.TEXT },
147
+ { name: 'author', dataType: dataType.TEXT },
148
+ ],
149
+ });
150
+ ```
151
+
152
+ #### Collection with Multiple Named Vectors
153
+
154
+ ```typescript
155
+ import { configure, dataType } from 'weaviate-client';
156
+
157
+ await client.collections.create({
158
+ name: 'MultiModalArticle',
159
+ properties: [
160
+ { name: 'title', dataType: dataType.TEXT },
161
+ { name: 'body', dataType: dataType.TEXT },
162
+ { name: 'image', dataType: dataType.BLOB },
163
+ ],
164
+ vectorizers: [
165
+ configure.namedVectors.text2VecOpenAI('text_vector', {
166
+ sourceProperties: ['title', 'body'],
167
+ }),
168
+ configure.namedVectors.multi2VecClip('image_vector', {
169
+ imageFields: ['image'],
170
+ }),
171
+ ],
172
+ });
173
+ ```
174
+
175
+ #### Collection with Generative Module
176
+
177
+ ```typescript
178
+ import { configure, dataType } from 'weaviate-client';
179
+
180
+ await client.collections.create({
181
+ name: 'Article',
182
+ vectorizers: configure.vectorizer.text2VecOpenAI(),
183
+ generative: configure.generative.openAI({
184
+ model: 'gpt-4',
185
+ }),
186
+ properties: [
187
+ { name: 'title', dataType: dataType.TEXT },
188
+ { name: 'body', dataType: dataType.TEXT },
189
+ ],
190
+ });
191
+ ```
192
+
193
+ ### List All Collections
194
+
195
+ ```typescript
196
+ const collections = await client.collections.listAll();
197
+ console.log(collections);
198
+ ```
199
+
200
+ ### Get a Collection Reference
201
+
202
+ ```typescript
203
+ const articles = client.collections.get('Article');
204
+ ```
205
+
206
+ ### Delete a Collection
207
+
208
+ ```typescript
209
+ await client.collections.delete('Article');
210
+ ```
211
+
212
+ ### Check if Collection Exists
213
+
214
+ ```typescript
215
+ const exists = await client.collections.exists('Article');
216
+ console.log(`Collection exists: ${exists}`);
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Data Types
222
+
223
+ ### Available Data Types
224
+
225
+ ```typescript
226
+ import { dataType } from 'weaviate-client';
227
+
228
+ // Text types
229
+ dataType.TEXT // Single text value
230
+ dataType.TEXT_ARRAY // Array of text values
231
+
232
+ // Numeric types
233
+ dataType.NUMBER // Float/double
234
+ dataType.INT // Integer
235
+ dataType.INT_ARRAY // Array of integers
236
+ dataType.NUMBER_ARRAY // Array of numbers
237
+
238
+ // Boolean
239
+ dataType.BOOLEAN // True/false
240
+ dataType.BOOLEAN_ARRAY // Array of booleans
241
+
242
+ // Date and UUID
243
+ dataType.DATE // ISO 8601 date-time
244
+ dataType.DATE_ARRAY // Array of dates
245
+ dataType.UUID // UUID
246
+ dataType.UUID_ARRAY // Array of UUIDs
247
+
248
+ // Binary data
249
+ dataType.BLOB // Base64 encoded binary data
250
+ dataType.BLOB_ARRAY // Array of blobs
251
+
252
+ // Geolocation
253
+ dataType.GEO_COORDINATES // { latitude: number, longitude: number }
254
+
255
+ // Object reference
256
+ dataType.OBJECT // Nested object
257
+ dataType.OBJECT_ARRAY // Array of nested objects
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Insert Data
263
+
264
+ ### Insert Single Object
265
+
266
+ ```typescript
267
+ const articles = client.collections.get('Article');
268
+
269
+ const uuid = await articles.data.insert({
270
+ title: 'Weaviate is Amazing',
271
+ body: 'A comprehensive guide to vector databases',
272
+ author: 'John Doe',
273
+ publishDate: new Date('2024-01-15').toISOString(),
274
+ viewCount: 1250,
275
+ });
276
+
277
+ console.log(`Inserted object with UUID: ${uuid}`);
278
+ ```
279
+
280
+ ### Insert with Custom UUID
281
+
282
+ ```typescript
283
+ import { generateUuid5 } from 'weaviate-client';
284
+
285
+ const myUuid = generateUuid5('my-unique-id');
286
+
287
+ await articles.data.insert({
288
+ title: 'Custom UUID Article',
289
+ body: 'Article with custom UUID',
290
+ }, { uuid: myUuid });
291
+ ```
292
+
293
+ ### Insert with Vector
294
+
295
+ ```typescript
296
+ const uuid = await articles.data.insert({
297
+ title: 'Manual Vector Article',
298
+ body: 'Article with manually provided vector',
299
+ }, {
300
+ vector: [0.1, 0.2, 0.3, ...], // Your embedding vector
301
+ });
302
+ ```
303
+
304
+ ### Batch Insert (insertMany)
305
+
306
+ ```typescript
307
+ const articles = client.collections.get('Article');
308
+
309
+ const dataObjects = [
310
+ {
311
+ title: 'First Article',
312
+ body: 'Content of first article',
313
+ author: 'Jane Smith',
314
+ },
315
+ {
316
+ title: 'Second Article',
317
+ body: 'Content of second article',
318
+ author: 'Bob Johnson',
319
+ },
320
+ {
321
+ title: 'Third Article',
322
+ body: 'Content of third article',
323
+ author: 'Alice Williams',
324
+ },
325
+ ];
326
+
327
+ const response = await articles.data.insertMany(dataObjects);
328
+
329
+ console.log(`Inserted ${response.uuids.length} objects`);
330
+ console.log('UUIDs:', response.uuids);
331
+
332
+ // Check for errors
333
+ if (response.hasErrors) {
334
+ console.error('Errors occurred:', response.errors);
335
+ }
336
+ ```
337
+
338
+ ### Batch Insert with Vectors
339
+
340
+ ```typescript
341
+ const dataWithVectors = [
342
+ {
343
+ title: 'Article 1',
344
+ body: 'Content 1',
345
+ vector: [0.1, 0.2, 0.3],
346
+ },
347
+ {
348
+ title: 'Article 2',
349
+ body: 'Content 2',
350
+ vector: [0.4, 0.5, 0.6],
351
+ },
352
+ ];
353
+
354
+ await articles.data.insertMany(dataWithVectors);
355
+ ```
356
+
357
+ ---
358
+
359
+ ## Query Data
360
+
361
+ ### Fetch Objects (No Search)
362
+
363
+ ```typescript
364
+ const articles = client.collections.get('Article');
365
+
366
+ const result = await articles.query.fetchObjects({
367
+ limit: 10,
368
+ offset: 0,
369
+ });
370
+
371
+ for (const object of result.objects) {
372
+ console.log(object.properties);
373
+ console.log(`UUID: ${object.uuid}`);
374
+ }
375
+ ```
376
+
377
+ ### Fetch by ID
378
+
379
+ ```typescript
380
+ const object = await articles.query.fetchObjectById(uuid);
381
+ console.log(object?.properties);
382
+ ```
383
+
384
+ ### Fetch with Filters
385
+
386
+ ```typescript
387
+ const result = await articles.query.fetchObjects({
388
+ filters: articles.filter.byProperty('viewCount').greaterThan(1000),
389
+ limit: 5,
390
+ });
391
+
392
+ for (const object of result.objects) {
393
+ console.log(object.properties);
394
+ }
395
+ ```
396
+
397
+ ---
398
+
399
+ ## Vector Search
400
+
401
+ ### nearText Search
402
+
403
+ ```typescript
404
+ const articles = client.collections.get('Article');
405
+
406
+ const result = await articles.query.nearText('vector databases', {
407
+ limit: 5,
408
+ returnMetadata: ['distance', 'score'],
409
+ });
410
+
411
+ for (const object of result.objects) {
412
+ console.log(object.properties);
413
+ console.log(`Distance: ${object.metadata?.distance}`);
414
+ console.log(`Score: ${object.metadata?.score}`);
415
+ }
416
+ ```
417
+
418
+ ### nearText with Filters
419
+
420
+ ```typescript
421
+ const result = await articles.query.nearText('machine learning', {
422
+ limit: 3,
423
+ filters: articles.filter.byProperty('author').equal('John Doe'),
424
+ returnMetadata: ['distance'],
425
+ });
426
+
427
+ for (const object of result.objects) {
428
+ console.log(object.properties);
429
+ }
430
+ ```
431
+
432
+ ### nearVector Search
433
+
434
+ ```typescript
435
+ const queryVector = [0.1, 0.2, 0.3, ...]; // Your query vector
436
+
437
+ const result = await articles.query.nearVector(queryVector, {
438
+ limit: 5,
439
+ returnMetadata: ['distance'],
440
+ });
441
+
442
+ for (const object of result.objects) {
443
+ console.log(object.properties);
444
+ }
445
+ ```
446
+
447
+ ### nearObject Search
448
+
449
+ ```typescript
450
+ const result = await articles.query.nearObject(existingUuid, {
451
+ limit: 5,
452
+ returnMetadata: ['distance'],
453
+ });
454
+
455
+ for (const object of result.objects) {
456
+ console.log(object.properties);
457
+ }
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Hybrid Search
463
+
464
+ Hybrid search combines keyword (BM25) and vector search.
465
+
466
+ ### Basic Hybrid Search
467
+
468
+ ```typescript
469
+ const articles = client.collections.get('Article');
470
+
471
+ const result = await articles.query.hybrid('artificial intelligence', {
472
+ limit: 10,
473
+ alpha: 0.5, // 0 = pure keyword, 1 = pure vector, 0.5 = balanced
474
+ });
475
+
476
+ for (const object of result.objects) {
477
+ console.log(object.properties);
478
+ }
479
+ ```
480
+
481
+ ### Hybrid Search with Filters
482
+
483
+ ```typescript
484
+ const result = await articles.query.hybrid('deep learning', {
485
+ limit: 5,
486
+ alpha: 0.75,
487
+ filters: articles.filter.byProperty('publishDate').greaterThan(
488
+ new Date('2024-01-01').toISOString()
489
+ ),
490
+ returnMetadata: ['score'],
491
+ });
492
+
493
+ for (const object of result.objects) {
494
+ console.log(object.properties);
495
+ console.log(`Score: ${object.metadata?.score}`);
496
+ }
497
+ ```
498
+
499
+ ### Hybrid Search with Vector
500
+
501
+ ```typescript
502
+ const result = await articles.query.hybrid('machine learning', {
503
+ limit: 5,
504
+ alpha: 0.5,
505
+ vector: [0.1, 0.2, 0.3, ...], // Optional manual vector
506
+ });
507
+ ```
508
+
509
+ ---
510
+
511
+ ## Filters
512
+
513
+ ### Basic Filters
514
+
515
+ ```typescript
516
+ const articles = client.collections.get('Article');
517
+
518
+ // Equal
519
+ articles.filter.byProperty('author').equal('John Doe')
520
+
521
+ // Not Equal
522
+ articles.filter.byProperty('author').notEqual('Jane Smith')
523
+
524
+ // Greater Than
525
+ articles.filter.byProperty('viewCount').greaterThan(1000)
526
+
527
+ // Greater Than or Equal
528
+ articles.filter.byProperty('viewCount').greaterOrEqual(500)
529
+
530
+ // Less Than
531
+ articles.filter.byProperty('viewCount').lessThan(2000)
532
+
533
+ // Less Than or Equal
534
+ articles.filter.byProperty('viewCount').lessOrEqual(1500)
535
+
536
+ // Like (text contains)
537
+ articles.filter.byProperty('title').like('*vector*')
538
+
539
+ // Contains Any
540
+ articles.filter.byProperty('author').containsAny(['John Doe', 'Jane Smith'])
541
+
542
+ // Is Null
543
+ articles.filter.byProperty('author').isNull(true)
544
+ ```
545
+
546
+ ### Combining Filters (AND)
547
+
548
+ ```typescript
549
+ const result = await articles.query.fetchObjects({
550
+ filters: articles.filter
551
+ .byProperty('viewCount').greaterThan(1000)
552
+ .and()
553
+ .byProperty('author').equal('John Doe'),
554
+ limit: 10,
555
+ });
556
+ ```
557
+
558
+ ### Combining Filters (OR)
559
+
560
+ ```typescript
561
+ const result = await articles.query.fetchObjects({
562
+ filters: articles.filter
563
+ .byProperty('author').equal('John Doe')
564
+ .or()
565
+ .byProperty('author').equal('Jane Smith'),
566
+ limit: 10,
567
+ });
568
+ ```
569
+
570
+ ### Complex Filter Combinations
571
+
572
+ ```typescript
573
+ const result = await articles.query.fetchObjects({
574
+ filters: articles.filter
575
+ .byProperty('viewCount').greaterThan(500)
576
+ .and()
577
+ .byProperty('publishDate').greaterThan(new Date('2024-01-01').toISOString())
578
+ .or()
579
+ .byProperty('author').equal('John Doe'),
580
+ limit: 10,
581
+ });
582
+ ```
583
+
584
+ ---
585
+
586
+ ## Generative Search (RAG)
587
+
588
+ Generative search pipes search results through an LLM.
589
+
590
+ ### Single Result Generation
591
+
592
+ ```typescript
593
+ const articles = client.collections.get('Article');
594
+
595
+ const result = await articles.generate.nearText('AI trends', {
596
+ singlePrompt: 'Summarize this article in one sentence: {title} - {body}',
597
+ limit: 5,
598
+ });
599
+
600
+ for (const object of result.objects) {
601
+ console.log('Article:', object.properties);
602
+ console.log('Generated:', object.generated);
603
+ }
604
+ ```
605
+
606
+ ### Grouped Task Generation
607
+
608
+ ```typescript
609
+ const result = await articles.generate.nearText('machine learning', {
610
+ groupedTask: 'Write a brief overview summarizing these articles about machine learning',
611
+ limit: 5,
612
+ });
613
+
614
+ console.log('Generated summary:', result.generated);
615
+
616
+ for (const object of result.objects) {
617
+ console.log('Source article:', object.properties.title);
618
+ }
619
+ ```
620
+
621
+ ### Both Single and Grouped
622
+
623
+ ```typescript
624
+ const result = await articles.generate.nearText('neural networks', {
625
+ singlePrompt: 'Explain this in simple terms: {body}',
626
+ groupedTask: 'Create a comprehensive guide based on all these articles',
627
+ limit: 5,
628
+ });
629
+
630
+ for (const object of result.objects) {
631
+ console.log('Article:', object.properties.title);
632
+ console.log('Individual generation:', object.generated);
633
+ }
634
+
635
+ console.log('Grouped generation:', result.generated);
636
+ ```
637
+
638
+ ### Generative Search with Filters
639
+
640
+ ```typescript
641
+ const result = await articles.generate.nearText('databases', {
642
+ singlePrompt: 'Summarize: {title}',
643
+ limit: 3,
644
+ filters: articles.filter.byProperty('author').equal('John Doe'),
645
+ });
646
+ ```
647
+
648
+ ### Generate with nearVector
649
+
650
+ ```typescript
651
+ const queryVector = [0.1, 0.2, 0.3, ...];
652
+
653
+ const result = await articles.generate.nearVector(queryVector, {
654
+ groupedTask: 'Create a summary of these related articles',
655
+ limit: 5,
656
+ });
657
+
658
+ console.log(result.generated);
659
+ ```
660
+
661
+ ---
662
+
663
+ ## Update Data
664
+
665
+ ### Update Object
666
+
667
+ ```typescript
668
+ const articles = client.collections.get('Article');
669
+
670
+ await articles.data.update({
671
+ id: uuid,
672
+ properties: {
673
+ viewCount: 2000,
674
+ title: 'Updated Title',
675
+ },
676
+ });
677
+ ```
678
+
679
+ ### Replace Object
680
+
681
+ Replace replaces the entire object (not a merge).
682
+
683
+ ```typescript
684
+ await articles.data.replace({
685
+ id: uuid,
686
+ properties: {
687
+ title: 'Completely New Title',
688
+ body: 'Completely new body',
689
+ author: 'New Author',
690
+ publishDate: new Date().toISOString(),
691
+ viewCount: 0,
692
+ },
693
+ });
694
+ ```
695
+
696
+ ---
697
+
698
+ ## Delete Data
699
+
700
+ ### Delete by ID
701
+
702
+ ```typescript
703
+ const articles = client.collections.get('Article');
704
+
705
+ await articles.data.deleteById(uuid);
706
+ console.log('Object deleted');
707
+ ```
708
+
709
+ ### Delete Many by Filter
710
+
711
+ ```typescript
712
+ const response = await articles.data.deleteMany(
713
+ articles.filter.byProperty('viewCount').lessThan(100)
714
+ );
715
+
716
+ console.log(`Deleted ${response.successful} objects`);
717
+ console.log(`Failed: ${response.failed}`);
718
+ ```
719
+
720
+ ### Delete All Objects in Collection
721
+
722
+ ```typescript
723
+ await articles.data.deleteMany(
724
+ articles.filter.byProperty('title').like('*')
725
+ );
726
+ ```
727
+
728
+ ---
729
+
730
+ ## Aggregations
731
+
732
+ ### Count Objects
733
+
734
+ ```typescript
735
+ const articles = client.collections.get('Article');
736
+
737
+ const result = await articles.aggregate.overAll();
738
+ console.log(`Total objects: ${result.totalCount}`);
739
+ ```
740
+
741
+ ### Count with Filter
742
+
743
+ ```typescript
744
+ const result = await articles.aggregate.overAll({
745
+ filters: articles.filter.byProperty('author').equal('John Doe'),
746
+ });
747
+
748
+ console.log(`Objects by John Doe: ${result.totalCount}`);
749
+ ```
750
+
751
+ ### Aggregate Numeric Properties
752
+
753
+ ```typescript
754
+ const result = await articles.aggregate.overAll({
755
+ returnMetrics: articles.metrics.number('viewCount').maximum(),
756
+ });
757
+
758
+ console.log(`Max views: ${result.properties.viewCount?.maximum}`);
759
+ ```
760
+
761
+ ### Multiple Aggregations
762
+
763
+ ```typescript
764
+ const result = await articles.aggregate.overAll({
765
+ returnMetrics: [
766
+ articles.metrics.number('viewCount').sum(),
767
+ articles.metrics.number('viewCount').average(),
768
+ articles.metrics.number('viewCount').minimum(),
769
+ articles.metrics.number('viewCount').maximum(),
770
+ ],
771
+ });
772
+
773
+ console.log('View count stats:', result.properties.viewCount);
774
+ ```
775
+
776
+ ---
777
+
778
+ ## Multi-Tenancy
779
+
780
+ ### Create Collection with Multi-Tenancy
781
+
782
+ ```typescript
783
+ import { configure, dataType } from 'weaviate-client';
784
+
785
+ await client.collections.create({
786
+ name: 'Article',
787
+ multiTenancyConfig: configure.multiTenancy({ enabled: true }),
788
+ properties: [
789
+ { name: 'title', dataType: dataType.TEXT },
790
+ { name: 'body', dataType: dataType.TEXT },
791
+ ],
792
+ });
793
+ ```
794
+
795
+ ### Add Tenants
796
+
797
+ ```typescript
798
+ const articles = client.collections.get('Article');
799
+
800
+ await articles.tenants.create([
801
+ { name: 'tenant1' },
802
+ { name: 'tenant2' },
803
+ { name: 'tenant3' },
804
+ ]);
805
+ ```
806
+
807
+ ### Get Tenant Reference
808
+
809
+ ```typescript
810
+ const tenant1Articles = articles.withTenant('tenant1');
811
+ ```
812
+
813
+ ### Insert Data for Tenant
814
+
815
+ ```typescript
816
+ await tenant1Articles.data.insert({
817
+ title: 'Tenant 1 Article',
818
+ body: 'This belongs to tenant 1',
819
+ });
820
+ ```
821
+
822
+ ### Query Tenant Data
823
+
824
+ ```typescript
825
+ const result = await tenant1Articles.query.fetchObjects({ limit: 10 });
826
+
827
+ for (const object of result.objects) {
828
+ console.log(object.properties);
829
+ }
830
+ ```
831
+
832
+ ### List Tenants
833
+
834
+ ```typescript
835
+ const tenants = await articles.tenants.get();
836
+ console.log(tenants);
837
+ ```
838
+
839
+ ### Remove Tenant
840
+
841
+ ```typescript
842
+ await articles.tenants.remove(['tenant3']);
843
+ ```
844
+
845
+ ---
846
+
847
+ ## Batch Operations
848
+
849
+ ### Batch with Error Handling
850
+
851
+ ```typescript
852
+ const articles = client.collections.get('Article');
853
+
854
+ const data = [
855
+ { title: 'Article 1', body: 'Content 1', author: 'Author 1' },
856
+ { title: 'Article 2', body: 'Content 2', author: 'Author 2' },
857
+ { title: 'Article 3', body: 'Content 3', author: 'Author 3' },
858
+ ];
859
+
860
+ const response = await articles.data.insertMany(data);
861
+
862
+ if (response.hasErrors) {
863
+ console.error('Batch insert had errors:');
864
+ for (let i = 0; i < response.errors.length; i++) {
865
+ if (response.errors[i]) {
866
+ console.error(`Object ${i}: ${response.errors[i]?.message}`);
867
+ }
868
+ }
869
+ }
870
+
871
+ console.log(`Successfully inserted: ${response.uuids.length} objects`);
872
+ ```
873
+
874
+ ---
875
+
876
+ ## Cross-References
877
+
878
+ ### Define Collection with Reference
879
+
880
+ ```typescript
881
+ import { dataType } from 'weaviate-client';
882
+
883
+ // Create Author collection
884
+ await client.collections.create({
885
+ name: 'Author',
886
+ properties: [
887
+ { name: 'name', dataType: dataType.TEXT },
888
+ { name: 'bio', dataType: dataType.TEXT },
889
+ ],
890
+ });
891
+
892
+ // Create Article collection with reference to Author
893
+ await client.collections.create({
894
+ name: 'Article',
895
+ properties: [
896
+ { name: 'title', dataType: dataType.TEXT },
897
+ { name: 'body', dataType: dataType.TEXT },
898
+ ],
899
+ references: [
900
+ {
901
+ name: 'hasAuthor',
902
+ targetCollection: 'Author',
903
+ },
904
+ ],
905
+ });
906
+ ```
907
+
908
+ ### Insert with Reference
909
+
910
+ ```typescript
911
+ const authors = client.collections.get('Author');
912
+ const articles = client.collections.get('Article');
913
+
914
+ // Insert author
915
+ const authorUuid = await authors.data.insert({
916
+ name: 'John Doe',
917
+ bio: 'Expert in AI',
918
+ });
919
+
920
+ // Insert article with reference
921
+ await articles.data.insert({
922
+ title: 'AI Article',
923
+ body: 'Content about AI',
924
+ }, {
925
+ references: {
926
+ hasAuthor: authorUuid,
927
+ },
928
+ });
929
+ ```
930
+
931
+ ### Query with References
932
+
933
+ ```typescript
934
+ const result = await articles.query.fetchObjects({
935
+ limit: 10,
936
+ returnReferences: [{
937
+ linkOn: 'hasAuthor',
938
+ returnProperties: ['name', 'bio'],
939
+ }],
940
+ });
941
+
942
+ for (const object of result.objects) {
943
+ console.log('Article:', object.properties);
944
+ console.log('Author:', object.references?.hasAuthor);
945
+ }
946
+ ```
947
+
948
+ ---
949
+
950
+ ## Advanced Configurations
951
+
952
+ ### Collection with Custom Vectorizer Settings
953
+
954
+ ```typescript
955
+ import { configure, dataType, vectorDistances } from 'weaviate-client';
956
+
957
+ await client.collections.create({
958
+ name: 'Article',
959
+ vectorizers: configure.vectorizer.text2VecOpenAI({
960
+ model: 'text-embedding-3-large',
961
+ dimensions: 1536,
962
+ vectorizeCollectionName: false,
963
+ }),
964
+ vectorIndexConfig: configure.vectorIndex.hnsw({
965
+ distanceMetric: vectorDistances.COSINE,
966
+ efConstruction: 128,
967
+ maxConnections: 64,
968
+ }),
969
+ properties: [
970
+ {
971
+ name: 'title',
972
+ dataType: dataType.TEXT,
973
+ vectorizePropertyName: false,
974
+ skipVectorization: false,
975
+ },
976
+ {
977
+ name: 'body',
978
+ dataType: dataType.TEXT,
979
+ },
980
+ {
981
+ name: 'metadata',
982
+ dataType: dataType.TEXT,
983
+ skipVectorization: true, // Don't vectorize this property
984
+ },
985
+ ],
986
+ });
987
+ ```
988
+
989
+ ### Collection with Inverted Index Config
990
+
991
+ ```typescript
992
+ import { configure, dataType, tokenization } from 'weaviate-client';
993
+
994
+ await client.collections.create({
995
+ name: 'Article',
996
+ properties: [
997
+ {
998
+ name: 'title',
999
+ dataType: dataType.TEXT,
1000
+ tokenization: tokenization.WORD,
1001
+ indexFilterable: true,
1002
+ indexSearchable: true,
1003
+ },
1004
+ {
1005
+ name: 'sku',
1006
+ dataType: dataType.TEXT,
1007
+ tokenization: tokenization.FIELD, // Exact match only
1008
+ indexFilterable: true,
1009
+ indexSearchable: false,
1010
+ },
1011
+ ],
1012
+ invertedIndexConfig: configure.invertedIndex({
1013
+ indexTimestamps: true,
1014
+ indexNullState: true,
1015
+ indexPropertyLength: true,
1016
+ }),
1017
+ });
1018
+ ```
1019
+
1020
+ ---
1021
+
1022
+ ## Error Handling
1023
+
1024
+ ### Try-Catch Pattern
1025
+
1026
+ ```typescript
1027
+ import weaviate from 'weaviate-client';
1028
+
1029
+ try {
1030
+ const client = await weaviate.connectToWeaviateCloud(
1031
+ process.env.WEAVIATE_URL!,
1032
+ {
1033
+ authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY!),
1034
+ }
1035
+ );
1036
+
1037
+ const articles = client.collections.get('Article');
1038
+
1039
+ const result = await articles.query.nearText('AI', { limit: 5 });
1040
+
1041
+ for (const object of result.objects) {
1042
+ console.log(object.properties);
1043
+ }
1044
+
1045
+ await client.close();
1046
+ } catch (error) {
1047
+ console.error('Error:', error);
1048
+ }
1049
+ ```
1050
+
1051
+ ### Batch Insert Error Handling
1052
+
1053
+ ```typescript
1054
+ const response = await articles.data.insertMany(dataObjects);
1055
+
1056
+ if (response.hasErrors) {
1057
+ response.errors.forEach((error, index) => {
1058
+ if (error) {
1059
+ console.error(`Error at index ${index}:`, error.message);
1060
+ }
1061
+ });
1062
+ }
1063
+
1064
+ console.log('Successful UUIDs:', response.uuids.filter(uuid => uuid !== null));
1065
+ ```
1066
+
1067
+ ---
1068
+
1069
+ ## Complete Example
1070
+
1071
+ ```typescript
1072
+ import weaviate, { WeaviateClient, dataType, configure } from 'weaviate-client';
1073
+
1074
+ async function main() {
1075
+ // Connect
1076
+ const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
1077
+ process.env.WEAVIATE_URL!,
1078
+ {
1079
+ authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY!),
1080
+ headers: {
1081
+ 'X-OpenAI-Api-Key': process.env.OPENAI_API_KEY!,
1082
+ }
1083
+ }
1084
+ );
1085
+
1086
+ console.log('Connected to Weaviate');
1087
+
1088
+ // Create collection
1089
+ await client.collections.create({
1090
+ name: 'Article',
1091
+ vectorizers: configure.vectorizer.text2VecOpenAI({
1092
+ model: 'text-embedding-3-small',
1093
+ }),
1094
+ generative: configure.generative.openAI({
1095
+ model: 'gpt-4',
1096
+ }),
1097
+ properties: [
1098
+ { name: 'title', dataType: dataType.TEXT },
1099
+ { name: 'body', dataType: dataType.TEXT },
1100
+ { name: 'author', dataType: dataType.TEXT },
1101
+ { name: 'publishDate', dataType: dataType.DATE },
1102
+ { name: 'viewCount', dataType: dataType.INT },
1103
+ ],
1104
+ });
1105
+
1106
+ console.log('Collection created');
1107
+
1108
+ // Get collection reference
1109
+ const articles = client.collections.get('Article');
1110
+
1111
+ // Insert data
1112
+ const dataObjects = [
1113
+ {
1114
+ title: 'Vector Databases Explained',
1115
+ body: 'A comprehensive guide to understanding vector databases and their applications in modern AI systems.',
1116
+ author: 'John Doe',
1117
+ publishDate: new Date('2024-01-15').toISOString(),
1118
+ viewCount: 1250,
1119
+ },
1120
+ {
1121
+ title: 'Machine Learning in Production',
1122
+ body: 'Best practices for deploying machine learning models in production environments.',
1123
+ author: 'Jane Smith',
1124
+ publishDate: new Date('2024-02-20').toISOString(),
1125
+ viewCount: 2100,
1126
+ },
1127
+ {
1128
+ title: 'Introduction to RAG',
1129
+ body: 'Retrieval Augmented Generation combines search with language models for better responses.',
1130
+ author: 'John Doe',
1131
+ publishDate: new Date('2024-03-10').toISOString(),
1132
+ viewCount: 890,
1133
+ },
1134
+ ];
1135
+
1136
+ const insertResponse = await articles.data.insertMany(dataObjects);
1137
+ console.log(`Inserted ${insertResponse.uuids.length} articles`);
1138
+
1139
+ // Vector search
1140
+ console.log('\n--- Vector Search ---');
1141
+ const searchResult = await articles.query.nearText('AI and databases', {
1142
+ limit: 2,
1143
+ returnMetadata: ['distance', 'score'],
1144
+ });
1145
+
1146
+ for (const object of searchResult.objects) {
1147
+ console.log(`\nTitle: ${object.properties.title}`);
1148
+ console.log(`Author: ${object.properties.author}`);
1149
+ console.log(`Score: ${object.metadata?.score}`);
1150
+ }
1151
+
1152
+ // Filtered search
1153
+ console.log('\n--- Filtered Search ---');
1154
+ const filteredResult = await articles.query.nearText('machine learning', {
1155
+ limit: 3,
1156
+ filters: articles.filter.byProperty('viewCount').greaterThan(1000),
1157
+ });
1158
+
1159
+ for (const object of filteredResult.objects) {
1160
+ console.log(`\nTitle: ${object.properties.title}`);
1161
+ console.log(`Views: ${object.properties.viewCount}`);
1162
+ }
1163
+
1164
+ // Hybrid search
1165
+ console.log('\n--- Hybrid Search ---');
1166
+ const hybridResult = await articles.query.hybrid('production deployment', {
1167
+ limit: 2,
1168
+ alpha: 0.5,
1169
+ });
1170
+
1171
+ for (const object of hybridResult.objects) {
1172
+ console.log(`\nTitle: ${object.properties.title}`);
1173
+ }
1174
+
1175
+ // Generative search (RAG)
1176
+ console.log('\n--- Generative Search ---');
1177
+ const ragResult = await articles.generate.nearText('vector databases', {
1178
+ singlePrompt: 'Summarize this article in one sentence: {title}',
1179
+ groupedTask: 'Write a brief paragraph about these articles',
1180
+ limit: 2,
1181
+ });
1182
+
1183
+ console.log('\nGrouped generation:');
1184
+ console.log(ragResult.generated);
1185
+
1186
+ for (const object of ragResult.objects) {
1187
+ console.log(`\n${object.properties.title}`);
1188
+ console.log(`Summary: ${object.generated}`);
1189
+ }
1190
+
1191
+ // Aggregate
1192
+ console.log('\n--- Aggregations ---');
1193
+ const aggResult = await articles.aggregate.overAll({
1194
+ returnMetrics: [
1195
+ articles.metrics.number('viewCount').sum(),
1196
+ articles.metrics.number('viewCount').average(),
1197
+ articles.metrics.number('viewCount').maximum(),
1198
+ ],
1199
+ });
1200
+
1201
+ console.log(`Total articles: ${aggResult.totalCount}`);
1202
+ console.log(`Total views: ${aggResult.properties.viewCount?.sum}`);
1203
+ console.log(`Average views: ${aggResult.properties.viewCount?.average}`);
1204
+ console.log(`Max views: ${aggResult.properties.viewCount?.maximum}`);
1205
+
1206
+ // Update
1207
+ const firstUuid = insertResponse.uuids[0];
1208
+ await articles.data.update({
1209
+ id: firstUuid,
1210
+ properties: {
1211
+ viewCount: 1500,
1212
+ },
1213
+ });
1214
+ console.log('\nUpdated first article view count');
1215
+
1216
+ // Delete by filter
1217
+ const deleteResult = await articles.data.deleteMany(
1218
+ articles.filter.byProperty('viewCount').lessThan(900)
1219
+ );
1220
+ console.log(`\nDeleted ${deleteResult.successful} low-view articles`);
1221
+
1222
+ // Cleanup
1223
+ await client.collections.delete('Article');
1224
+ console.log('\nCollection deleted');
1225
+
1226
+ await client.close();
1227
+ console.log('Connection closed');
1228
+ }
1229
+
1230
+ main().catch(console.error);
1231
+ ```
1232
+
1233
+ ---
1234
+
1235
+ ## TypeScript Types
1236
+
1237
+ ```typescript
1238
+ import type {
1239
+ WeaviateClient,
1240
+ Collection,
1241
+ QueryReturn,
1242
+ GenerativeReturn,
1243
+ } from 'weaviate-client';
1244
+
1245
+ // Collection reference type
1246
+ const articles: Collection<{
1247
+ title: string;
1248
+ body: string;
1249
+ author: string;
1250
+ publishDate: string;
1251
+ viewCount: number;
1252
+ }> = client.collections.get('Article');
1253
+
1254
+ // Query result type
1255
+ const result: QueryReturn<{
1256
+ title: string;
1257
+ body: string;
1258
+ author: string;
1259
+ }> = await articles.query.nearText('AI', { limit: 5 });
1260
+
1261
+ // Generative result type
1262
+ const genResult: GenerativeReturn<{
1263
+ title: string;
1264
+ body: string;
1265
+ }> = await articles.generate.nearText('AI', {
1266
+ singlePrompt: 'Summarize: {title}',
1267
+ });
1268
+ ```