@mastra/pg 1.7.1 → 1.7.2

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.
@@ -4,27 +4,27 @@ The PgVector class provides vector search using [PostgreSQL](https://www.postgre
4
4
 
5
5
  ## Constructor Options
6
6
 
7
- **connectionString?:** (`string`): PostgreSQL connection URL
7
+ **connectionString** (`string`): PostgreSQL connection URL
8
8
 
9
- **host?:** (`string`): PostgreSQL server host
9
+ **host** (`string`): PostgreSQL server host
10
10
 
11
- **port?:** (`number`): PostgreSQL server port
11
+ **port** (`number`): PostgreSQL server port
12
12
 
13
- **database?:** (`string`): PostgreSQL database name
13
+ **database** (`string`): PostgreSQL database name
14
14
 
15
- **user?:** (`string`): PostgreSQL user
15
+ **user** (`string`): PostgreSQL user
16
16
 
17
- **password?:** (`string`): PostgreSQL password
17
+ **password** (`string`): PostgreSQL password
18
18
 
19
- **ssl?:** (`boolean | ConnectionOptions`): Enable SSL or provide custom SSL configuration
19
+ **ssl** (`boolean | ConnectionOptions`): Enable SSL or provide custom SSL configuration
20
20
 
21
- **schemaName?:** (`string`): The name of the schema you want the vector store to use. Will use the default schema if not provided.
21
+ **schemaName** (`string`): The name of the schema you want the vector store to use. Will use the default schema if not provided.
22
22
 
23
- **max?:** (`number`): Maximum number of pool connections (default: 20)
23
+ **max** (`number`): Maximum number of pool connections (default: 20)
24
24
 
25
- **idleTimeoutMillis?:** (`number`): Idle connection timeout in milliseconds (default: 30000)
25
+ **idleTimeoutMillis** (`number`): Idle connection timeout in milliseconds (default: 30000)
26
26
 
27
- **pgPoolOptions?:** (`PoolConfig`): Additional pg pool configuration options
27
+ **pgPoolOptions** (`PoolConfig`): Additional pg pool configuration options
28
28
 
29
29
  ## Constructor Examples
30
30
 
@@ -72,23 +72,35 @@ const vectorStore = new PgVector({
72
72
 
73
73
  ### createIndex()
74
74
 
75
- **indexName:** (`string`): Name of the index to create
75
+ **indexName** (`string`): Name of the index to create
76
76
 
77
- **dimension:** (`number`): Vector dimension (must match your embedding model)
77
+ **dimension** (`number`): Vector dimension (must match your embedding model)
78
78
 
79
- **metric?:** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
79
+ **metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
80
80
 
81
- **indexConfig?:** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
81
+ **indexConfig** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
82
82
 
83
- **buildIndex?:** (`boolean`): Whether to build the index (Default: `true`)
83
+ **buildIndex** (`boolean`): Whether to build the index (Default: `true`)
84
84
 
85
85
  #### IndexConfig
86
86
 
87
- **type:** (`'flat' | 'hnsw' | 'ivfflat'`): stringflat:flatSequential scan (no index) that performs exhaustive search.ivfflat:ivfflatClusters vectors into lists for approximate search.hnsw:hnswGraph-based index offering fast search times and high recall. (Default: `ivfflat`)
87
+ **type** (`'flat' | 'hnsw' | 'ivfflat'`): Index type (Default: `ivfflat`)
88
88
 
89
- **ivf?:** (`IVFConfig`): objectlists?:numberNumber of lists. If not specified, automatically calculated based on dataset size. (Minimum 100, Maximum 4000)
89
+ **type.flat** (`flat`): Sequential scan (no index) that performs exhaustive search.
90
90
 
91
- **hnsw?:** (`HNSWConfig`): objectm?:numberMaximum number of connections per node (default: 8)efConstruction?:numberBuild-time complexity (default: 32)
91
+ **type.ivfflat** (`ivfflat`): Clusters vectors into lists for approximate search.
92
+
93
+ **type.hnsw** (`hnsw`): Graph-based index offering fast search times and high recall.
94
+
95
+ **ivf** (`IVFConfig`): IVF configuration
96
+
97
+ **ivf.lists** (`number`): Number of lists. If not specified, automatically calculated based on dataset size. (Minimum 100, Maximum 4000)
98
+
99
+ **hnsw** (`HNSWConfig`): HNSW configuration
100
+
101
+ **hnsw\.m** (`number`): Maximum number of connections per node (default: 8)
102
+
103
+ **hnsw\.efConstruction** (`number`): Build-time complexity (default: 32)
92
104
 
93
105
  #### Memory Requirements
94
106
 
@@ -102,29 +114,33 @@ Higher M values or efConstruction values will increase memory requirements signi
102
114
 
103
115
  ### upsert()
104
116
 
105
- **indexName:** (`string`): Name of the index to upsert vectors into
117
+ **indexName** (`string`): Name of the index to upsert vectors into
106
118
 
107
- **vectors:** (`number[][]`): Array of embedding vectors
119
+ **vectors** (`number[][]`): Array of embedding vectors
108
120
 
109
- **metadata?:** (`Record<string, any>[]`): Metadata for each vector
121
+ **metadata** (`Record<string, any>[]`): Metadata for each vector
110
122
 
111
- **ids?:** (`string[]`): Optional vector IDs (auto-generated if not provided)
123
+ **ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
112
124
 
113
125
  ### query()
114
126
 
115
- **indexName:** (`string`): Name of the index to query
127
+ **indexName** (`string`): Name of the index to query
128
+
129
+ **queryVector** (`number[]`): Query vector
130
+
131
+ **topK** (`number`): Number of results to return (Default: `10`)
116
132
 
117
- **queryVector:** (`number[]`): Query vector
133
+ **filter** (`Record<string, any>`): Metadata filters
118
134
 
119
- **topK?:** (`number`): Number of results to return (Default: `10`)
135
+ **includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
120
136
 
121
- **filter?:** (`Record<string, any>`): Metadata filters
137
+ **minScore** (`number`): Minimum similarity score threshold (Default: `0`)
122
138
 
123
- **includeVector?:** (`boolean`): Whether to include the vector in the result (Default: `false`)
139
+ **options** (`{ ef?: number; probes?: number }`): Additional options for HNSW and IVF indexes
124
140
 
125
- **minScore?:** (`number`): Minimum similarity score threshold (Default: `0`)
141
+ **options.ef** (`number`): HNSW search parameter
126
142
 
127
- **options?:** (`{ ef?: number; probes?: number }`): objectef?:numberHNSW search parameterprobes?:numberIVF search parameter
143
+ **options.probes** (`number`): IVF search parameter
128
144
 
129
145
  ### listIndexes()
130
146
 
@@ -132,7 +148,7 @@ Returns an array of index names as strings.
132
148
 
133
149
  ### describeIndex()
134
150
 
135
- **indexName:** (`string`): Name of the index to describe
151
+ **indexName** (`string`): Name of the index to describe
136
152
 
137
153
  Returns:
138
154
 
@@ -153,19 +169,19 @@ interface PGIndexStats {
153
169
 
154
170
  ### deleteIndex()
155
171
 
156
- **indexName:** (`string`): Name of the index to delete
172
+ **indexName** (`string`): Name of the index to delete
157
173
 
158
174
  ### updateVector()
159
175
 
160
176
  Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
161
177
 
162
- **indexName:** (`string`): Name of the index containing the vector
178
+ **indexName** (`string`): Name of the index containing the vector
163
179
 
164
- **id?:** (`string`): ID of the vector to update (mutually exclusive with filter)
180
+ **id** (`string`): ID of the vector to update (mutually exclusive with filter)
165
181
 
166
- **filter?:** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
182
+ **filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
167
183
 
168
- **update:** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
184
+ **update** (`{ vector?: number[]; metadata?: Record<string, any>; }`): Object containing the vector and/or metadata to update
169
185
 
170
186
  Updates an existing vector by ID or filter. At least one of vector or metadata must be provided in the update object.
171
187
 
@@ -192,9 +208,9 @@ await pgVector.updateVector({
192
208
 
193
209
  ### deleteVector()
194
210
 
195
- **indexName:** (`string`): Name of the index containing the vector
211
+ **indexName** (`string`): Name of the index containing the vector
196
212
 
197
- **id:** (`string`): ID of the vector to delete
213
+ **id** (`string`): ID of the vector to delete
198
214
 
199
215
  Deletes a single vector by ID from the specified index.
200
216
 
@@ -206,11 +222,11 @@ await pgVector.deleteVector({ indexName: 'my_vectors', id: 'vector123' })
206
222
 
207
223
  Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
208
224
 
209
- **indexName:** (`string`): Name of the index containing the vectors to delete
225
+ **indexName** (`string`): Name of the index containing the vectors to delete
210
226
 
211
- **ids?:** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
227
+ **ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
212
228
 
213
- **filter?:** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
229
+ **filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
214
230
 
215
231
  ### disconnect()
216
232
 
@@ -218,11 +234,11 @@ Closes the database connection pool. Should be called when done using the store.
218
234
 
219
235
  ### buildIndex()
220
236
 
221
- **indexName:** (`string`): Name of the index to define
237
+ **indexName** (`string`): Name of the index to define
222
238
 
223
- **metric?:** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
239
+ **metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
224
240
 
225
- **indexConfig:** (`IndexConfig`): Configuration for the index type and parameters
241
+ **indexConfig** (`IndexConfig`): Configuration for the index type and parameters
226
242
 
227
243
  Builds or rebuilds an index with specified metric and configuration. Will drop any existing index before creating the new one.
228
244
 
package/dist/index.cjs CHANGED
@@ -5187,6 +5187,10 @@ var ExperimentsPG = class _ExperimentsPG extends storage.ExperimentsStorage {
5187
5187
  setClauses.push(`"failedCount" = $${paramIndex++}`);
5188
5188
  values.push(input.failedCount);
5189
5189
  }
5190
+ if (input.totalItems !== void 0) {
5191
+ setClauses.push(`"totalItems" = $${paramIndex++}`);
5192
+ values.push(input.totalItems);
5193
+ }
5190
5194
  if (input.skippedCount !== void 0) {
5191
5195
  setClauses.push(`"skippedCount" = $${paramIndex++}`);
5192
5196
  values.push(input.skippedCount);