@mastra/oracledb 0.0.0 → 0.2.0-alpha.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.
- package/LICENSE.md +30 -0
- package/dist/docs/SKILL.md +37 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-memory-observational-memory.md +835 -0
- package/dist/docs/references/docs-memory-semantic-recall.md +402 -0
- package/dist/docs/references/docs-memory-working-memory.md +432 -0
- package/dist/docs/references/docs-storage-overview.md +215 -0
- package/dist/docs/references/guides-rag-overview.md +74 -0
- package/dist/docs/references/guides-rag-retrieval.md +537 -0
- package/dist/docs/references/guides-rag-vector-databases.md +710 -0
- package/dist/docs/references/reference-rag-metadata-filters.md +227 -0
- package/dist/docs/references/reference-storage-oracledb.md +239 -0
- package/dist/docs/references/reference-vectors-oracledb.md +347 -0
- package/dist/index.cjs +10217 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10196 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +27 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/shared/connection.d.ts +46 -0
- package/dist/shared/connection.d.ts.map +1 -0
- package/dist/storage/db/index.d.ts +128 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domain-utils.d.ts +18 -0
- package/dist/storage/domain-utils.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +54 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-clients/index.d.ts +46 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +88 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/messages.d.ts +37 -0
- package/dist/storage/domains/memory/messages.d.ts.map +1 -0
- package/dist/storage/domains/memory/observational-buffering.d.ts +7 -0
- package/dist/storage/domains/memory/observational-buffering.d.ts.map +1 -0
- package/dist/storage/domains/memory/observational.d.ts +56 -0
- package/dist/storage/domains/memory/observational.d.ts.map +1 -0
- package/dist/storage/domains/memory/resources.d.ts +14 -0
- package/dist/storage/domains/memory/resources.d.ts.map +1 -0
- package/dist/storage/domains/memory/schema.d.ts +43 -0
- package/dist/storage/domains/memory/schema.d.ts.map +1 -0
- package/dist/storage/domains/memory/threads.d.ts +37 -0
- package/dist/storage/domains/memory/threads.d.ts.map +1 -0
- package/dist/storage/domains/memory/utils.d.ts +68 -0
- package/dist/storage/domains/memory/utils.d.ts.map +1 -0
- package/dist/storage/domains/observability/binds.d.ts +21 -0
- package/dist/storage/domains/observability/binds.d.ts.map +1 -0
- package/dist/storage/domains/observability/index.d.ts +49 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/logs.d.ts +5 -0
- package/dist/storage/domains/observability/logs.d.ts.map +1 -0
- package/dist/storage/domains/observability/schema.d.ts +38 -0
- package/dist/storage/domains/observability/schema.d.ts.map +1 -0
- package/dist/storage/domains/observability/scores-bridge.d.ts +7 -0
- package/dist/storage/domains/observability/scores-bridge.d.ts.map +1 -0
- package/dist/storage/domains/observability/spans.d.ts +18 -0
- package/dist/storage/domains/observability/spans.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +46 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +63 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +61 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +45 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/migrations.d.ts +55 -0
- package/dist/storage/migrations.d.ts.map +1 -0
- package/dist/storage/types.d.ts +44 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/vector/ddl.d.ts +58 -0
- package/dist/vector/ddl.d.ts.map +1 -0
- package/dist/vector/filter.d.ts +7 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/identifiers.d.ts +11 -0
- package/dist/vector/identifiers.d.ts.map +1 -0
- package/dist/vector/index.d.ts +32 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/prompt.d.ts +6 -0
- package/dist/vector/prompt.d.ts.map +1 -0
- package/dist/vector/query.d.ts +5 -0
- package/dist/vector/query.d.ts.map +1 -0
- package/dist/vector/sql.d.ts +12 -0
- package/dist/vector/sql.d.ts.map +1 -0
- package/dist/vector/stats.d.ts +9 -0
- package/dist/vector/stats.d.ts.map +1 -0
- package/dist/vector/types.d.ts +80 -0
- package/dist/vector/types.d.ts.map +1 -0
- package/dist/vector/upsert.d.ts +20 -0
- package/dist/vector/upsert.d.ts.map +1 -0
- package/package.json +23 -24
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# Metadata filters
|
|
4
|
+
|
|
5
|
+
Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax. Each vector store translates these filters into its native query format. For example, PgVector uses PostgreSQL JSONB predicates, while OracleDB stores metadata as Oracle JSON and compiles filters to `JSON_VALUE`, `JSON_EXISTS`, `REGEXP_LIKE`, and `LIKE` predicates with bound values.
|
|
6
|
+
|
|
7
|
+
## Basic example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { PgVector } from '@mastra/pg'
|
|
11
|
+
|
|
12
|
+
const store = new PgVector({
|
|
13
|
+
id: 'pg-vector',
|
|
14
|
+
connectionString,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const results = await store.query({
|
|
18
|
+
indexName: 'my_index',
|
|
19
|
+
queryVector: queryVector,
|
|
20
|
+
topK: 10,
|
|
21
|
+
filter: {
|
|
22
|
+
category: 'electronics', // Simple equality
|
|
23
|
+
price: { $gt: 100 }, // Numeric comparison
|
|
24
|
+
tags: { $in: ['sale', 'new'] }, // Array membership
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Supported operators
|
|
30
|
+
|
|
31
|
+
### Basic Comparison
|
|
32
|
+
|
|
33
|
+
`$eq`Matches values equal to specified value{ age: { $eq: 25 } }Supported by: All except Couchbase`$ne`Matches values not equal{ status: { $ne: 'inactive' } }Supported by: All except Couchbase`$gt`Greater than{ price: { $gt: 100 } }Supported by: All except Couchbase`$gte`Greater than or equal{ rating: { $gte: 4.5 } }Supported by: All except Couchbase`$lt`Less than{ stock: { $lt: 20 } }Supported by: All except Couchbase`$lte`Less than or equal{ priority: { $lte: 3 } }Supported by: All except Couchbase
|
|
34
|
+
|
|
35
|
+
### Array Operators
|
|
36
|
+
|
|
37
|
+
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB, OracleDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB, OracleDB
|
|
38
|
+
|
|
39
|
+
### Logical Operators
|
|
40
|
+
|
|
41
|
+
`$and`Logical AND{ $and: \[{ price: { $gt: 100 } }, { stock: { $gt: 0 } }] }Supported by: All except Vectorize, Couchbase`$or`Logical OR{ $or: \[{ status: "active" }, { priority: "high" }] }Supported by: All except Vectorize, Couchbase`$not`Logical NOT{ price: { $not: { $lt: 100 } } }Supported by: Astra, Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB`$nor`Logical NOR{ $nor: \[{ status: "deleted" }, { archived: true }] }Supported by: Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB
|
|
42
|
+
|
|
43
|
+
### Element Operators
|
|
44
|
+
|
|
45
|
+
`$exists`Matches documents with field{ rating: { $exists: true } }Supported by: All except Vectorize, Chroma, Couchbase
|
|
46
|
+
|
|
47
|
+
### Custom Operators
|
|
48
|
+
|
|
49
|
+
`$contains`Text contains substring{ description: { $contains: "sale" } }Supported by: Upstash, libSQL, PgVector, OracleDB`$regex`Regular expression match{ name: { $regex: "^test" } }Supported by: Qdrant, PgVector, Upstash, MongoDB, OracleDB`$size`Array length check{ tags: { $size: 3 } }Supported by: Astra, libSQL, PgVector, MongoDB, OracleDB`$geo`Geospatial query{ location: { $geo: { type: "radius", ... } } }Supported by: Qdrant`$datetime`Datetime range query{ created: { $datetime: { range: { gt: "2024-01-01" } } } }Supported by: Qdrant`$hasId`Vector ID existence check{ $hasId: \["id1", "id2"] }Supported by: Qdrant`$hasVector`Vector existence check{ $hasVector: true }Supported by: Qdrant
|
|
50
|
+
|
|
51
|
+
## Common rules and restrictions
|
|
52
|
+
|
|
53
|
+
1. Field names can't:
|
|
54
|
+
|
|
55
|
+
- Contain dots (.) unless referring to nested fields
|
|
56
|
+
- Start with $ or contain null characters
|
|
57
|
+
- Be empty strings
|
|
58
|
+
|
|
59
|
+
2. Values must be:
|
|
60
|
+
|
|
61
|
+
- Valid JSON types (string, number, boolean, object, array)
|
|
62
|
+
- Not undefined
|
|
63
|
+
- Properly typed for the operator (e.g., numbers for numeric comparisons)
|
|
64
|
+
|
|
65
|
+
3. Logical operators:
|
|
66
|
+
|
|
67
|
+
- Must contain valid conditions
|
|
68
|
+
- Can't be empty
|
|
69
|
+
- Must be properly nested
|
|
70
|
+
- Can only be used at top level or nested within other logical operators
|
|
71
|
+
- Can't be used at field level or nested inside a field
|
|
72
|
+
- Can't be used inside an operator
|
|
73
|
+
- Valid: `{ "$and": [{ "field": { "$gt": 100 } }] }`
|
|
74
|
+
- Valid: `{ "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }`
|
|
75
|
+
- Invalid: `{ "field": { "$and": [{ "$gt": 100 }] } }`
|
|
76
|
+
- Invalid: `{ "field": { "$gt": { "$and": [{...}] } } }`
|
|
77
|
+
|
|
78
|
+
4. $not operator:
|
|
79
|
+
|
|
80
|
+
- Must be an object
|
|
81
|
+
- Can't be empty
|
|
82
|
+
- Can be used at field level or top level
|
|
83
|
+
- Valid: `{ "$not": { "field": "value" } }`
|
|
84
|
+
- Valid: `{ "field": { "$not": { "$eq": "value" } } }`
|
|
85
|
+
|
|
86
|
+
5. Operator nesting:
|
|
87
|
+
|
|
88
|
+
- Logical operators must contain field conditions, not direct operators
|
|
89
|
+
- Valid: `{ "$and": [{ "field": { "$gt": 100 } }] }`
|
|
90
|
+
- Invalid: `{ "$and": [{ "$gt": 100 }] }`
|
|
91
|
+
|
|
92
|
+
## Store-specific notes
|
|
93
|
+
|
|
94
|
+
### Astra
|
|
95
|
+
|
|
96
|
+
- Nested field queries are supported using dot notation
|
|
97
|
+
- Array fields must be explicitly defined as arrays in the metadata
|
|
98
|
+
- Metadata values are case-sensitive
|
|
99
|
+
|
|
100
|
+
### ChromaDB
|
|
101
|
+
|
|
102
|
+
- Where filters only return results where the filtered field exists in metadata
|
|
103
|
+
- Empty metadata fields aren't included in filter results
|
|
104
|
+
- Metadata fields must be present for negative matches (e.g., $ne won't match documents missing the field)
|
|
105
|
+
|
|
106
|
+
### Cloudflare Vectorize
|
|
107
|
+
|
|
108
|
+
- Requires explicit metadata indexing before filtering can be used
|
|
109
|
+
- Use `createMetadataIndex()` to index fields you want to filter on
|
|
110
|
+
- Up to 10 metadata indexes per Vectorize index
|
|
111
|
+
- String values are indexed up to first 64 bytes (truncated on UTF-8 boundaries)
|
|
112
|
+
- Number values use float64 precision
|
|
113
|
+
- Filter JSON must be under 2048 bytes
|
|
114
|
+
- Field names can't contain dots (.) or start with $
|
|
115
|
+
- Field names limited to 512 characters
|
|
116
|
+
- Vectors must be re-upserted after creating new metadata indexes to be included in filtered results
|
|
117
|
+
- Range queries may have reduced accuracy with very large datasets (\~10M+ vectors)
|
|
118
|
+
|
|
119
|
+
### libSQL
|
|
120
|
+
|
|
121
|
+
- Supports nested object queries with dot notation
|
|
122
|
+
- Array fields are validated to ensure they contain valid JSON arrays
|
|
123
|
+
- Numeric comparisons maintain proper type handling
|
|
124
|
+
- Empty arrays in conditions are handled gracefully
|
|
125
|
+
- Metadata is stored in a JSONB column for efficient querying
|
|
126
|
+
|
|
127
|
+
### OracleDB
|
|
128
|
+
|
|
129
|
+
- Metadata is stored as Oracle JSON alongside each `VECTOR` row
|
|
130
|
+
- Scalar comparisons use `JSON_VALUE`, while array, existence, and element-match checks use `JSON_EXISTS`
|
|
131
|
+
- `$regex` uses Oracle `REGEXP_LIKE`; string `$contains` uses case-insensitive `LIKE`
|
|
132
|
+
- Nested fields are supported with dot notation and are converted to quoted Oracle JSON paths
|
|
133
|
+
- User-provided metadata values are bound as parameters instead of interpolated into SQL
|
|
134
|
+
|
|
135
|
+
### PgVector
|
|
136
|
+
|
|
137
|
+
- Full support for PostgreSQL's native JSON querying capabilities
|
|
138
|
+
- Efficient handling of array operations using native array functions
|
|
139
|
+
- Proper type handling for numbers, strings, and booleans
|
|
140
|
+
- Nested field queries use PostgreSQL's JSON path syntax internally
|
|
141
|
+
- Metadata is stored in a JSONB column for efficient indexing
|
|
142
|
+
|
|
143
|
+
### Pinecone
|
|
144
|
+
|
|
145
|
+
- Metadata field names are limited to 512 characters
|
|
146
|
+
- Numeric values must be within the range of ±1e38
|
|
147
|
+
- Arrays in metadata are limited to 64KB total size
|
|
148
|
+
- Nested objects are flattened with dot notation
|
|
149
|
+
- Metadata updates replace the entire metadata object
|
|
150
|
+
|
|
151
|
+
### Qdrant
|
|
152
|
+
|
|
153
|
+
- Supports advanced filtering with nested conditions
|
|
154
|
+
- Payload (metadata) fields must be explicitly indexed for filtering
|
|
155
|
+
- Use `createPayloadIndex()` to index fields you want to filter on:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
// Index a field before filtering on it
|
|
159
|
+
await store.createPayloadIndex({
|
|
160
|
+
indexName: 'my_index',
|
|
161
|
+
fieldName: 'source',
|
|
162
|
+
fieldSchema: 'keyword', // 'keyword' | 'integer' | 'float' | 'geo' | 'text' | 'bool' | 'datetime' | 'uuid'
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// Now filtering works
|
|
166
|
+
const results = await store.query({
|
|
167
|
+
indexName: 'my_index',
|
|
168
|
+
queryVector: queryVector,
|
|
169
|
+
filter: { source: 'document-a' },
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
- Efficient handling of geo-spatial queries
|
|
174
|
+
- Special handling for null and empty values
|
|
175
|
+
- Vector-specific filtering capabilities
|
|
176
|
+
- Datetime values must be in RFC 3339 format
|
|
177
|
+
|
|
178
|
+
### Upstash
|
|
179
|
+
|
|
180
|
+
- 512-character limit for metadata field keys
|
|
181
|
+
- Query size is limited (avoid large IN clauses)
|
|
182
|
+
- No support for null/undefined values in filters
|
|
183
|
+
- Translates to SQL-like syntax internally
|
|
184
|
+
- Case-sensitive string comparisons
|
|
185
|
+
- Metadata updates are atomic
|
|
186
|
+
|
|
187
|
+
### MongoDB
|
|
188
|
+
|
|
189
|
+
- Full support for MongoDB/Sift query syntax for metadata filters
|
|
190
|
+
- Supports all standard comparison, array, logical, and element operators
|
|
191
|
+
- Supports nested fields and arrays in metadata
|
|
192
|
+
- Filtering can be applied to both `metadata` and the original document content using the `filter` and `documentFilter` options, respectively
|
|
193
|
+
- `filter` applies to the metadata object; `documentFilter` applies to the original document fields
|
|
194
|
+
- No artificial limits on filter size or complexity (subject to MongoDB query limits)
|
|
195
|
+
- Indexing metadata fields is recommended for optimal performance
|
|
196
|
+
|
|
197
|
+
### Couchbase
|
|
198
|
+
|
|
199
|
+
- Currently doesn't have support for metadata filters. Filtering must be done client-side after retrieving results or by using the Couchbase SDK's Search capabilities directly for more complex queries.
|
|
200
|
+
|
|
201
|
+
### Amazon S3 Vectors
|
|
202
|
+
|
|
203
|
+
- Equality values must be primitives (string/number/boolean). `null`/`undefined`, arrays, objects, and Date aren't allowed for equality. Range operators accept numbers or Date (Dates are normalized to epoch ms).
|
|
204
|
+
- `$in`/`$nin` require **non-empty arrays of primitives**; Date elements are allowed and normalized to epoch ms. **Array equality** isn't supported.
|
|
205
|
+
- Implicit AND is canonicalized (`{a:1,b:2}` → `{$and:[{a:1},{b:2}]`). Logical operators must contain field conditions and use non-empty arrays. They may appear only at the root or within other logical operators (not inside field values).
|
|
206
|
+
- Keys listed in `nonFilterableMetadataKeys` at index creation are stored but not filterable. This setting is immutable.
|
|
207
|
+
- $exists requires a boolean value.
|
|
208
|
+
- undefined/null/empty filters are treated as no filter.
|
|
209
|
+
- Each metadata key name limited to 63 characters.
|
|
210
|
+
- Total metadata per vector: Up to 40 KB (filterable + non-filterable)
|
|
211
|
+
- Total metadata keys per vector: Up to 10
|
|
212
|
+
- Filterable metadata per vector: Up to 2 KB
|
|
213
|
+
- Non-filterable metadata keys per vector index: Up to 10
|
|
214
|
+
|
|
215
|
+
## Related
|
|
216
|
+
|
|
217
|
+
- [Astra](https://mastra.ai/reference/vectors/astra)
|
|
218
|
+
- [Chroma](https://mastra.ai/reference/vectors/chroma)
|
|
219
|
+
- [Cloudflare Vectorize](https://mastra.ai/reference/vectors/vectorize)
|
|
220
|
+
- [libSQL](https://mastra.ai/reference/vectors/libsql)
|
|
221
|
+
- [MongoDB](https://mastra.ai/reference/vectors/mongodb)
|
|
222
|
+
- [OracleDB](https://mastra.ai/reference/vectors/oracledb)
|
|
223
|
+
- [PgStore](https://mastra.ai/reference/vectors/pg)
|
|
224
|
+
- [Pinecone](https://mastra.ai/reference/vectors/pinecone)
|
|
225
|
+
- [Qdrant](https://mastra.ai/reference/vectors/qdrant)
|
|
226
|
+
- [Upstash](https://mastra.ai/reference/vectors/upstash)
|
|
227
|
+
- [Amazon S3 Vectors](https://mastra.ai/reference/vectors/s3vectors)
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
3
|
+
# OracleDB storage
|
|
4
|
+
|
|
5
|
+
The OracleDB storage provider stores Mastra application state in Oracle Database. It implements Mastra's composite storage interface, so one `OracleStore` instance can back memory, workflow snapshots, observability, scores, scorer definitions, MCP client metadata, and agent registry data.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
**npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @mastra/oracledb@latest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**pnpm**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @mastra/oracledb@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Yarn**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @mastra/oracledb@latest
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Bun**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun add @mastra/oracledb@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { OracleStore } from '@mastra/oracledb'
|
|
37
|
+
|
|
38
|
+
const storage = new OracleStore({
|
|
39
|
+
id: 'oracle-storage',
|
|
40
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
41
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
42
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use it with Mastra:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { Mastra } from '@mastra/core/mastra'
|
|
50
|
+
|
|
51
|
+
export const mastra = new Mastra({
|
|
52
|
+
storage,
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Parameters
|
|
57
|
+
|
|
58
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
59
|
+
|
|
60
|
+
**user** (`string`): Oracle Database user. Required unless using pool or externalAuth.
|
|
61
|
+
|
|
62
|
+
**password** (`string`): Password for the Oracle Database user. Required unless using pool or externalAuth.
|
|
63
|
+
|
|
64
|
+
**connectString** (`string`): Oracle connect string, service name, TNS alias, or Autonomous Database connect descriptor. Required unless using pool.
|
|
65
|
+
|
|
66
|
+
**pool** (`oracledb.Pool`): Existing Oracle connection pool. When provided, Mastra uses the pool but doesn't close it when store.close() is called.
|
|
67
|
+
|
|
68
|
+
**poolManager** (`OraclePoolManager`): Shared Oracle pool manager. Use this to share one Oracle pool between OracleStore and OracleVector.
|
|
69
|
+
|
|
70
|
+
**schemaName** (`string`): Oracle schema name used to qualify storage tables.
|
|
71
|
+
|
|
72
|
+
**poolMin** (`number`): Minimum number of Oracle pool connections. (Default: `0`)
|
|
73
|
+
|
|
74
|
+
**poolMax** (`number`): Maximum number of Oracle pool connections. (Default: `4`)
|
|
75
|
+
|
|
76
|
+
**poolIncrement** (`number`): Number of connections to add when the pool grows. (Default: `1`)
|
|
77
|
+
|
|
78
|
+
**configDir** (`string`): Directory containing Oracle Network configuration files such as tnsnames.ora.
|
|
79
|
+
|
|
80
|
+
**walletLocation** (`string`): Oracle wallet directory for mTLS connections such as Autonomous Database.
|
|
81
|
+
|
|
82
|
+
**walletPassword** (`string`): Password for the Oracle wallet, when required by the wallet configuration.
|
|
83
|
+
|
|
84
|
+
**externalAuth** (`boolean`): Use Oracle external authentication instead of username/password authentication.
|
|
85
|
+
|
|
86
|
+
**disableInit** (`boolean`): When true, automatic schema initialization is disabled. Use this when schema changes are applied separately before the app starts. (Default: `false`)
|
|
87
|
+
|
|
88
|
+
**messageBatchSize** (`number`): Number of messages sent per Oracle executeMany call when saving messages. The operation still commits once at the transaction boundary. (Default: `200`)
|
|
89
|
+
|
|
90
|
+
**skipDefaultIndexes** (`boolean`): When true, default storage indexes aren't created during initialization.
|
|
91
|
+
|
|
92
|
+
**indexes** (`OracleCreateIndexOptions[]`): Custom Oracle index definitions to create during initialization. Indexes are routed to the storage domain that owns the target table.
|
|
93
|
+
|
|
94
|
+
**migrationTableName** (`string`): Oracle table used to track storage schema migrations. (Default: `'MASTRA_ORACLE_MIGRATIONS'`)
|
|
95
|
+
|
|
96
|
+
**vectorRegistryTableName** (`string`): OracleVector registry table used to discover semantic-recall vector tables when threads or messages are deleted. Set this to match OracleVector's registryTableName when that option is customized.
|
|
97
|
+
|
|
98
|
+
## Connection examples
|
|
99
|
+
|
|
100
|
+
The basic username/password constructor is shown above. For Autonomous Database, add wallet options to the same constructor:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const storage = new OracleStore({
|
|
104
|
+
id: 'oracle-storage',
|
|
105
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
106
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
107
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
108
|
+
walletLocation: process.env.ORACLE_DATABASE_WALLET_DIR,
|
|
109
|
+
walletPassword: process.env.ORACLE_DATABASE_WALLET_PASSWORD,
|
|
110
|
+
configDir: process.env.ORACLE_DATABASE_CONFIG_DIR,
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
For external authentication, set `externalAuth: true` and omit `password`. To reuse an existing `oracledb.Pool`, pass it as `pool`. Mastra uses it but doesn't close it.
|
|
115
|
+
|
|
116
|
+
`OracleStore` backs memory, workflow snapshots, observability, scores, scorer definitions, MCP client metadata, and agent registry data. When using the store outside a `Mastra` instance, call `await storage.init()` and access a domain with `await storage.getStore('memory')`.
|
|
117
|
+
|
|
118
|
+
## Initialization
|
|
119
|
+
|
|
120
|
+
When you pass `OracleStore` to `Mastra`, `init()` is called automatically before storage operations run. If you use `OracleStore` directly, call `init()` before reading or writing:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
await storage.init()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
> **Warning:** If initialization is disabled or skipped, storage operations require the Oracle tables and indexes to already exist.
|
|
127
|
+
|
|
128
|
+
`OracleStore.init()` runs repeatable migrations and records the result in the migration ledger table. The default ledger table is `MASTRA_ORACLE_MIGRATIONS`.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
await storage.migrate()
|
|
132
|
+
const history = await storage.listMigrations()
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Repeatable migrations are idempotent. They reconcile the tables and indexes owned by each storage domain on startup, which lets new domain indexes or compatible schema additions apply without changing application code.
|
|
136
|
+
|
|
137
|
+
Initialization also creates the provider's default indexes for common Mastra query paths. Use `skipDefaultIndexes` when indexes are managed separately, or pass `indexes` for custom Oracle indexes. Custom definitions support Oracle options such as `bitmap`, `online`, `invisible`, `parallel`, `compress`, `noLogging`, and `reverse`, as well as function-based expressions like `JSON_VALUE(...)`.
|
|
138
|
+
|
|
139
|
+
Custom indexes are useful when your app repeatedly filters on JSON metadata or when database administrators (DBAs) want to test an index before the optimizer uses it:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const storage = new OracleStore({
|
|
143
|
+
id: 'oracle-storage',
|
|
144
|
+
user,
|
|
145
|
+
password,
|
|
146
|
+
connectString,
|
|
147
|
+
indexes: [
|
|
148
|
+
{
|
|
149
|
+
name: 'idx_messages_status',
|
|
150
|
+
table: 'mastra_messages',
|
|
151
|
+
columns: [
|
|
152
|
+
"JSON_VALUE(metadata, '$.status' RETURNING VARCHAR2(32) NULL ON ERROR)",
|
|
153
|
+
'thread_id',
|
|
154
|
+
],
|
|
155
|
+
online: true,
|
|
156
|
+
invisible: true,
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
})
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use `invisible` for staged rollout, then remove it after validating query plans. Use `skipDefaultIndexes: true` only when a DBA-managed indexing strategy replaces the defaults.
|
|
163
|
+
|
|
164
|
+
Use `disableInit: true` when schema changes are applied by a separate deployment step or by a database administrator.
|
|
165
|
+
|
|
166
|
+
## Schema export
|
|
167
|
+
|
|
168
|
+
Use `exportSchemas()` to generate Oracle DDL without connecting to a database. This is useful when schema changes are reviewed or applied outside application startup.
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { exportSchemas } from '@mastra/oracledb'
|
|
172
|
+
|
|
173
|
+
const ddl = exportSchemas({
|
|
174
|
+
schemaName: 'MASTRA_APP',
|
|
175
|
+
domains: [
|
|
176
|
+
'memory',
|
|
177
|
+
'workflows',
|
|
178
|
+
'observability',
|
|
179
|
+
'scores',
|
|
180
|
+
'scorerDefinitions',
|
|
181
|
+
'mcpClients',
|
|
182
|
+
'agents',
|
|
183
|
+
],
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
console.log(ddl)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
`domains` defaults to every supported domain, including `vector`, when omitted.
|
|
190
|
+
|
|
191
|
+
## Operational notes
|
|
192
|
+
|
|
193
|
+
Use the same `OraclePoolManager` when `OracleStore` and `OracleVector` should share one Oracle connection lifecycle:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { OracleStore, OracleVector } from '@mastra/oracledb'
|
|
197
|
+
|
|
198
|
+
const storage = new OracleStore({ id: 'oracle-storage', user, password, connectString })
|
|
199
|
+
const vector = new OracleVector({
|
|
200
|
+
id: 'oracle-vector',
|
|
201
|
+
poolManager: storage.getPoolManager(),
|
|
202
|
+
})
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`OracleStore` exposes `storage.db` and `await storage.getPool()` for advanced use cases. When using these APIs directly, you're responsible for transaction boundaries and connection lifecycle.
|
|
206
|
+
|
|
207
|
+
JSON metadata, payloads, and snapshots are stored in native Oracle JSON columns and encoded server-side, so the rows are readable directly with standard Oracle JDBC tools such as DBeaver and SQL Developer.
|
|
208
|
+
|
|
209
|
+
## Usage example
|
|
210
|
+
|
|
211
|
+
### Adding OracleDB memory to an agent
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import { Agent } from '@mastra/core/agent'
|
|
215
|
+
import { Memory } from '@mastra/memory'
|
|
216
|
+
import { OracleStore } from '@mastra/oracledb'
|
|
217
|
+
|
|
218
|
+
const storage = new OracleStore({
|
|
219
|
+
id: 'oracle-storage',
|
|
220
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
221
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
222
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
export const oracleAgent = new Agent({
|
|
226
|
+
id: 'oracle-agent',
|
|
227
|
+
name: 'Oracle Agent',
|
|
228
|
+
instructions: 'You are an assistant with persistent OracleDB-backed memory.',
|
|
229
|
+
model: 'openai/gpt-5.6-sol',
|
|
230
|
+
memory: new Memory({ storage }),
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Related
|
|
235
|
+
|
|
236
|
+
- [OracleDB vector store](https://mastra.ai/reference/vectors/oracledb)
|
|
237
|
+
- [Storage overview](https://mastra.ai/reference/storage/overview)
|
|
238
|
+
- [Working memory](https://mastra.ai/docs/memory/working-memory)
|
|
239
|
+
- [Workflow snapshots](https://mastra.ai/docs/workflows/snapshots)
|