@mastra/mongodb 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnextAgentNetwork-20250527102918
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.
- package/CHANGELOG.md +172 -2
- package/README.md +50 -0
- package/dist/_tsup-dts-rollup.d.cts +153 -24
- package/dist/_tsup-dts-rollup.d.ts +153 -24
- package/dist/index.cjs +596 -31
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +596 -32
- package/docker-compose.yaml +30 -0
- package/package.json +8 -5
- package/src/index.ts +1 -0
- package/src/storage/index.test.ts +778 -0
- package/src/storage/index.ts +675 -0
- package/src/vector/index.test.ts +26 -13
- package/src/vector/index.ts +89 -48
- package/docker-compose.yml +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,185 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-vnextAgentNetwork-20250527102918
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 4a8cd1c: MongoDBStore option support
|
|
8
|
+
- fcc915f: Support MongoDB database as store
|
|
9
|
+
- Updated dependencies [6d16390]
|
|
10
|
+
- Updated dependencies [1e4a421]
|
|
11
|
+
- Updated dependencies [200d0da]
|
|
12
|
+
- Updated dependencies [bf5f17b]
|
|
13
|
+
- Updated dependencies [5343f93]
|
|
14
|
+
- Updated dependencies [38aee50]
|
|
15
|
+
- Updated dependencies [5c41100]
|
|
16
|
+
- Updated dependencies [d6a759b]
|
|
17
|
+
- @mastra/core@0.0.0-vnextAgentNetwork-20250527102918
|
|
18
|
+
|
|
19
|
+
## 0.10.1-alpha.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- fcc915f: Support MongoDB database as store
|
|
24
|
+
- Updated dependencies [6d16390]
|
|
25
|
+
- Updated dependencies [1e4a421]
|
|
26
|
+
- @mastra/core@0.10.1-alpha.0
|
|
27
|
+
|
|
28
|
+
## 0.10.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
37
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
38
|
+
- Updated dependencies [b3a3d63]
|
|
39
|
+
- Updated dependencies [344f453]
|
|
40
|
+
- Updated dependencies [0a3ae6d]
|
|
41
|
+
- Updated dependencies [95911be]
|
|
42
|
+
- Updated dependencies [f53a6ac]
|
|
43
|
+
- Updated dependencies [5eb5a99]
|
|
44
|
+
- Updated dependencies [7e632c5]
|
|
45
|
+
- Updated dependencies [1e9fbfa]
|
|
46
|
+
- Updated dependencies [eabdcd9]
|
|
47
|
+
- Updated dependencies [90be034]
|
|
48
|
+
- Updated dependencies [99f050a]
|
|
49
|
+
- Updated dependencies [d0ee3c6]
|
|
50
|
+
- Updated dependencies [b2ae5aa]
|
|
51
|
+
- Updated dependencies [23f258c]
|
|
52
|
+
- Updated dependencies [a7292b0]
|
|
53
|
+
- Updated dependencies [0dcb9f0]
|
|
54
|
+
- Updated dependencies [2672a05]
|
|
55
|
+
- @mastra/core@0.10.0
|
|
56
|
+
|
|
57
|
+
## 0.1.0-alpha.1
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
|
|
66
|
+
- Updated dependencies [b3a3d63]
|
|
67
|
+
- Updated dependencies [344f453]
|
|
68
|
+
- Updated dependencies [0a3ae6d]
|
|
69
|
+
- Updated dependencies [95911be]
|
|
70
|
+
- Updated dependencies [5eb5a99]
|
|
71
|
+
- Updated dependencies [7e632c5]
|
|
72
|
+
- Updated dependencies [1e9fbfa]
|
|
73
|
+
- Updated dependencies [b2ae5aa]
|
|
74
|
+
- Updated dependencies [a7292b0]
|
|
75
|
+
- Updated dependencies [0dcb9f0]
|
|
76
|
+
- @mastra/core@0.10.0-alpha.1
|
|
77
|
+
|
|
78
|
+
## 0.0.6-alpha.0
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
|
|
83
|
+
- Updated dependencies [f53a6ac]
|
|
84
|
+
- Updated dependencies [eabdcd9]
|
|
85
|
+
- Updated dependencies [90be034]
|
|
86
|
+
- Updated dependencies [99f050a]
|
|
87
|
+
- Updated dependencies [d0ee3c6]
|
|
88
|
+
- Updated dependencies [23f258c]
|
|
89
|
+
- Updated dependencies [2672a05]
|
|
90
|
+
- @mastra/core@0.9.5-alpha.0
|
|
91
|
+
|
|
92
|
+
## 0.0.5
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
97
|
+
- Updated dependencies [396be50]
|
|
98
|
+
- Updated dependencies [ab80e7e]
|
|
99
|
+
- Updated dependencies [c3bd795]
|
|
100
|
+
- Updated dependencies [da082f8]
|
|
101
|
+
- Updated dependencies [a5810ce]
|
|
102
|
+
- Updated dependencies [3e9c131]
|
|
103
|
+
- Updated dependencies [3171b5b]
|
|
104
|
+
- Updated dependencies [973e5ac]
|
|
105
|
+
- Updated dependencies [daf942f]
|
|
106
|
+
- Updated dependencies [0b8b868]
|
|
107
|
+
- Updated dependencies [9e1eff5]
|
|
108
|
+
- Updated dependencies [6fa1ad1]
|
|
109
|
+
- Updated dependencies [c28d7a0]
|
|
110
|
+
- Updated dependencies [edf1e88]
|
|
111
|
+
- @mastra/core@0.9.4
|
|
112
|
+
|
|
113
|
+
## 0.0.5-alpha.4
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- Updated dependencies [3e9c131]
|
|
118
|
+
- @mastra/core@0.9.4-alpha.4
|
|
119
|
+
|
|
120
|
+
## 0.0.5-alpha.3
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
|
|
125
|
+
- Updated dependencies [396be50]
|
|
126
|
+
- Updated dependencies [c3bd795]
|
|
127
|
+
- Updated dependencies [da082f8]
|
|
128
|
+
- Updated dependencies [a5810ce]
|
|
129
|
+
- @mastra/core@0.9.4-alpha.3
|
|
130
|
+
|
|
131
|
+
## 0.0.5-alpha.2
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [3171b5b]
|
|
136
|
+
- Updated dependencies [973e5ac]
|
|
137
|
+
- Updated dependencies [9e1eff5]
|
|
138
|
+
- @mastra/core@0.9.4-alpha.2
|
|
139
|
+
|
|
140
|
+
## 0.0.5-alpha.1
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [ab80e7e]
|
|
145
|
+
- Updated dependencies [6fa1ad1]
|
|
146
|
+
- Updated dependencies [c28d7a0]
|
|
147
|
+
- Updated dependencies [edf1e88]
|
|
148
|
+
- @mastra/core@0.9.4-alpha.1
|
|
149
|
+
|
|
150
|
+
## 0.0.5-alpha.0
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- Updated dependencies [daf942f]
|
|
155
|
+
- Updated dependencies [0b8b868]
|
|
156
|
+
- @mastra/core@0.9.4-alpha.0
|
|
157
|
+
|
|
158
|
+
## 0.0.4
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [e450778]
|
|
163
|
+
- Updated dependencies [8902157]
|
|
164
|
+
- Updated dependencies [ca0dc88]
|
|
7
165
|
- Updated dependencies [526c570]
|
|
166
|
+
- Updated dependencies [d7a6a33]
|
|
8
167
|
- Updated dependencies [9cd1a46]
|
|
9
168
|
- Updated dependencies [b5d2de0]
|
|
10
169
|
- Updated dependencies [644f8ad]
|
|
11
170
|
- Updated dependencies [70dbf51]
|
|
12
|
-
- @mastra/core@0.
|
|
171
|
+
- @mastra/core@0.9.3
|
|
172
|
+
|
|
173
|
+
## 0.0.4-alpha.1
|
|
174
|
+
|
|
175
|
+
### Patch Changes
|
|
176
|
+
|
|
177
|
+
- Updated dependencies [e450778]
|
|
178
|
+
- Updated dependencies [8902157]
|
|
179
|
+
- Updated dependencies [ca0dc88]
|
|
180
|
+
- Updated dependencies [9cd1a46]
|
|
181
|
+
- Updated dependencies [70dbf51]
|
|
182
|
+
- @mastra/core@0.9.3-alpha.1
|
|
13
183
|
|
|
14
184
|
## 0.0.4-alpha.0
|
|
15
185
|
|
package/README.md
CHANGED
|
@@ -56,6 +56,40 @@ const results = await vectorDB.query({
|
|
|
56
56
|
await vectorDB.disconnect();
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Storage
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { MongoDBStore } from '@mastra/mongodb';
|
|
63
|
+
|
|
64
|
+
const store = new MongoDBStore({
|
|
65
|
+
uri: 'mongodb://mongodb:mongodb@localhost:27018/?authSource=admin&directConnection=true',
|
|
66
|
+
dbName: 'mastra',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Create a thread
|
|
70
|
+
await store.saveThread({
|
|
71
|
+
id: 'thread-123',
|
|
72
|
+
resourceId: 'resource-456',
|
|
73
|
+
title: 'My Thread',
|
|
74
|
+
metadata: { key: 'value' },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Add messages to thread
|
|
78
|
+
await store.saveMessages([
|
|
79
|
+
{
|
|
80
|
+
id: 'msg-789',
|
|
81
|
+
threadId: 'thread-123',
|
|
82
|
+
role: 'user',
|
|
83
|
+
type: 'text',
|
|
84
|
+
content: [{ type: 'text', text: 'Hello' }],
|
|
85
|
+
},
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
// Query threads and messages
|
|
89
|
+
const savedThread = await store.getThread('thread-123');
|
|
90
|
+
const messages = await store.getMessages('thread-123');
|
|
91
|
+
```
|
|
92
|
+
|
|
59
93
|
## Configuration
|
|
60
94
|
|
|
61
95
|
The MongoDB vector store is initialized with:
|
|
@@ -83,6 +117,13 @@ const vectorDB = new MongoDBVector({
|
|
|
83
117
|
- Collection (index) management: create, list, describe, delete
|
|
84
118
|
- Atlas Search readiness checks for reliable testing
|
|
85
119
|
|
|
120
|
+
### Storage Features
|
|
121
|
+
|
|
122
|
+
- Thread and message storage with JSON support
|
|
123
|
+
- Efficient batch operations
|
|
124
|
+
- Rich metadata support
|
|
125
|
+
- Timestamp tracking
|
|
126
|
+
|
|
86
127
|
## Supported Filter Operators
|
|
87
128
|
|
|
88
129
|
- Comparison: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`
|
|
@@ -121,6 +162,15 @@ The following distance metrics are supported:
|
|
|
121
162
|
- `deleteIndex(indexName)`: Delete a collection
|
|
122
163
|
- `disconnect()`: Close the MongoDB connection
|
|
123
164
|
|
|
165
|
+
## Storage Methods
|
|
166
|
+
|
|
167
|
+
- `saveThread(thread)`: Create or update a thread
|
|
168
|
+
- `getThread(threadId)`: Get a thread by ID
|
|
169
|
+
- `deleteThread(threadId)`: Delete a thread and its messages
|
|
170
|
+
- `saveMessages(messages)`: Save multiple messages in a transaction
|
|
171
|
+
- `getMessages(threadId)`: Get all messages for a thread
|
|
172
|
+
- `deleteMessages(messageIds)`: Delete specific messages
|
|
173
|
+
|
|
124
174
|
## Query Response Format
|
|
125
175
|
|
|
126
176
|
Each query result includes:
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
+
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
4
|
+
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
5
|
+
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
6
|
+
import type { EvalRow } from '@mastra/core/storage';
|
|
3
7
|
import type { IndexStats } from '@mastra/core/vector';
|
|
8
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
4
9
|
import { MastraVector } from '@mastra/core/vector';
|
|
10
|
+
import type { MessageType } from '@mastra/core/memory';
|
|
5
11
|
import type { MongoClientOptions } from 'mongodb';
|
|
6
12
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
7
|
-
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
8
13
|
import type { QueryResult } from '@mastra/core/vector';
|
|
9
|
-
import type { QueryVectorArgs } from '@mastra/core/vector';
|
|
10
14
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
11
|
-
import type {
|
|
15
|
+
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
16
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
17
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
18
|
+
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
12
19
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
13
20
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
21
|
+
import type { WorkflowRun } from '@mastra/core/storage';
|
|
22
|
+
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
14
23
|
|
|
15
24
|
/**
|
|
16
25
|
* Vector store specific prompt that details supported operators and examples.
|
|
@@ -20,6 +29,14 @@ declare const MONGODB_PROMPT = "When querying MongoDB Vector, you can ONLY use t
|
|
|
20
29
|
export { MONGODB_PROMPT }
|
|
21
30
|
export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
22
31
|
|
|
32
|
+
declare interface MongoDBConfig {
|
|
33
|
+
url: string;
|
|
34
|
+
dbName: string;
|
|
35
|
+
options?: MongoClientOptions;
|
|
36
|
+
}
|
|
37
|
+
export { MongoDBConfig }
|
|
38
|
+
export { MongoDBConfig as MongoDBConfig_alias_1 }
|
|
39
|
+
|
|
23
40
|
/**
|
|
24
41
|
* Translator for MongoDB filter queries.
|
|
25
42
|
* Maintains MongoDB-compatible syntax while ensuring proper validation
|
|
@@ -33,9 +50,13 @@ export declare class MongoDBFilterTranslator extends BaseFilterTranslator {
|
|
|
33
50
|
isEmpty(filter: any): boolean;
|
|
34
51
|
}
|
|
35
52
|
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
declare interface MongoDBIndexReadyParams {
|
|
54
|
+
indexName: string;
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
checkIntervalMs?: number;
|
|
57
|
+
}
|
|
58
|
+
export { MongoDBIndexReadyParams }
|
|
59
|
+
export { MongoDBIndexReadyParams as MongoDBIndexReadyParams_alias_1 }
|
|
39
60
|
|
|
40
61
|
declare interface MongoDBQueryVectorParams extends QueryVectorParams {
|
|
41
62
|
documentFilter?: VectorFilter;
|
|
@@ -43,13 +64,93 @@ declare interface MongoDBQueryVectorParams extends QueryVectorParams {
|
|
|
43
64
|
export { MongoDBQueryVectorParams }
|
|
44
65
|
export { MongoDBQueryVectorParams as MongoDBQueryVectorParams_alias_1 }
|
|
45
66
|
|
|
46
|
-
declare
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
67
|
+
declare class MongoDBStore extends MastraStorage {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(config: MongoDBConfig);
|
|
70
|
+
private getConnection;
|
|
71
|
+
private getCollection;
|
|
72
|
+
createTable(): Promise<void>;
|
|
73
|
+
clearTable({ tableName }: {
|
|
74
|
+
tableName: TABLE_NAMES;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
insert({ tableName, record }: {
|
|
77
|
+
tableName: TABLE_NAMES;
|
|
78
|
+
record: Record<string, any>;
|
|
79
|
+
}): Promise<void>;
|
|
80
|
+
batchInsert({ tableName, records }: {
|
|
81
|
+
tableName: TABLE_NAMES;
|
|
82
|
+
records: Record<string, any>[];
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
load<R>({ tableName, keys }: {
|
|
85
|
+
tableName: TABLE_NAMES;
|
|
86
|
+
keys: Record<string, string>;
|
|
87
|
+
}): Promise<R | null>;
|
|
88
|
+
getThreadById({ threadId }: {
|
|
89
|
+
threadId: string;
|
|
90
|
+
}): Promise<StorageThreadType | null>;
|
|
91
|
+
getThreadsByResourceId({ resourceId }: {
|
|
92
|
+
resourceId: string;
|
|
93
|
+
}): Promise<StorageThreadType[]>;
|
|
94
|
+
saveThread({ thread }: {
|
|
95
|
+
thread: StorageThreadType;
|
|
96
|
+
}): Promise<StorageThreadType>;
|
|
97
|
+
updateThread({ id, title, metadata, }: {
|
|
98
|
+
id: string;
|
|
99
|
+
title: string;
|
|
100
|
+
metadata: Record<string, unknown>;
|
|
101
|
+
}): Promise<StorageThreadType>;
|
|
102
|
+
deleteThread({ threadId }: {
|
|
103
|
+
threadId: string;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
|
|
106
|
+
saveMessages({ messages }: {
|
|
107
|
+
messages: MessageType[];
|
|
108
|
+
}): Promise<MessageType[]>;
|
|
109
|
+
getTraces({ name, scope, page, perPage, attributes, filters, }?: {
|
|
110
|
+
name?: string;
|
|
111
|
+
scope?: string;
|
|
112
|
+
page: number;
|
|
113
|
+
perPage: number;
|
|
114
|
+
attributes?: Record<string, string>;
|
|
115
|
+
filters?: Record<string, any>;
|
|
116
|
+
}): Promise<any[]>;
|
|
117
|
+
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, }?: {
|
|
118
|
+
workflowName?: string;
|
|
119
|
+
fromDate?: Date;
|
|
120
|
+
toDate?: Date;
|
|
121
|
+
limit?: number;
|
|
122
|
+
offset?: number;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
runs: Array<{
|
|
125
|
+
workflowName: string;
|
|
126
|
+
runId: string;
|
|
127
|
+
snapshot: WorkflowRunState | string;
|
|
128
|
+
createdAt: Date;
|
|
129
|
+
updatedAt: Date;
|
|
130
|
+
}>;
|
|
131
|
+
total: number;
|
|
132
|
+
}>;
|
|
133
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
134
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
135
|
+
workflowName: string;
|
|
136
|
+
runId: string;
|
|
137
|
+
snapshot: WorkflowRunState;
|
|
138
|
+
}): Promise<void>;
|
|
139
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
140
|
+
workflowName: string;
|
|
141
|
+
runId: string;
|
|
142
|
+
}): Promise<WorkflowRunState | null>;
|
|
143
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
144
|
+
runId: string;
|
|
145
|
+
workflowName?: string;
|
|
146
|
+
}): Promise<WorkflowRun | null>;
|
|
147
|
+
private parseWorkflowRun;
|
|
148
|
+
private parseRow;
|
|
149
|
+
private transformEvalRow;
|
|
150
|
+
close(): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
export { MongoDBStore }
|
|
153
|
+
export { MongoDBStore as MongoDBStore_alias_1 }
|
|
53
154
|
|
|
54
155
|
declare interface MongoDBUpsertVectorParams extends UpsertVectorParams {
|
|
55
156
|
documents?: string[];
|
|
@@ -73,18 +174,46 @@ declare class MongoDBVector extends MastraVector {
|
|
|
73
174
|
});
|
|
74
175
|
connect(): Promise<void>;
|
|
75
176
|
disconnect(): Promise<void>;
|
|
76
|
-
createIndex(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
177
|
+
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Waits for the index to be ready.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} indexName - The name of the index to wait for
|
|
182
|
+
* @param {number} timeoutMs - The maximum time in milliseconds to wait for the index to be ready (default: 60000)
|
|
183
|
+
* @param {number} checkIntervalMs - The interval in milliseconds at which to check if the index is ready (default: 2000)
|
|
184
|
+
* @returns A promise that resolves when the index is ready
|
|
185
|
+
*/
|
|
186
|
+
waitForIndexReady({ indexName, timeoutMs, checkIntervalMs, }: MongoDBIndexReadyParams): Promise<void>;
|
|
187
|
+
upsert({ indexName, vectors, metadata, ids, documents }: MongoDBUpsertVectorParams): Promise<string[]>;
|
|
188
|
+
query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: MongoDBQueryVectorParams): Promise<QueryResult[]>;
|
|
80
189
|
listIndexes(): Promise<string[]>;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves statistics about a vector index.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} indexName - The name of the index to describe
|
|
194
|
+
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
195
|
+
*/
|
|
196
|
+
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
197
|
+
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
200
|
+
* @param indexName - The name of the index containing the vector.
|
|
201
|
+
* @param id - The ID of the vector to update.
|
|
202
|
+
* @param update - An object containing the vector and/or metadata to update.
|
|
203
|
+
* @param update.vector - An optional array of numbers representing the new vector.
|
|
204
|
+
* @param update.metadata - An optional record containing the new metadata.
|
|
205
|
+
* @returns A promise that resolves when the update is complete.
|
|
206
|
+
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
207
|
+
*/
|
|
208
|
+
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Deletes a vector by its ID.
|
|
211
|
+
* @param indexName - The name of the index containing the vector.
|
|
212
|
+
* @param id - The ID of the vector to delete.
|
|
213
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
214
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
215
|
+
*/
|
|
216
|
+
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
88
217
|
private getCollection;
|
|
89
218
|
private validateVectorDimensions;
|
|
90
219
|
private setIndexDimension;
|