-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdata-engine.ts
More file actions
52 lines (44 loc) · 1.8 KB
/
Copy pathdata-engine.ts
File metadata and controls
52 lines (44 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import {
EngineQueryOptions,
DataEngineInsertOptions,
EngineUpdateOptions,
EngineDeleteOptions,
EngineAggregateOptions,
EngineCountOptions,
DataEngineRequest,
} from '../data/index.js';
/**
* IDataEngine - Standard Data Engine Interface
*
* Abstract interface for data persistence capabilities.
* Following the Dependency Inversion Principle - plugins depend on this interface,
* not on concrete database implementations.
*
* All query methods use standard QueryAST parameter names
* (where/fields/orderBy/limit/offset/expand) to eliminate mechanical translation
* between the Engine and Driver layers.
*
* Aligned with 'src/data/data-engine.zod.ts' in @objectstack/spec.
*/
export interface IDataEngine {
find(objectName: string, query?: EngineQueryOptions): Promise<any[]>;
findOne(objectName: string, query?: EngineQueryOptions): Promise<any>;
insert(objectName: string, data: any | any[], options?: DataEngineInsertOptions): Promise<any>;
update(objectName: string, data: any, options?: EngineUpdateOptions): Promise<any>;
delete(objectName: string, options?: EngineDeleteOptions): Promise<any>;
count(objectName: string, query?: EngineCountOptions): Promise<number>;
aggregate(objectName: string, query: EngineAggregateOptions): Promise<any[]>;
/**
* Vector Search (AI/RAG)
*/
vectorFind?(objectName: string, vector: number[], options?: { where?: any, limit?: number, fields?: string[], threshold?: number }): Promise<any[]>;
/**
* Batch Operations (Transactional)
*/
batch?(requests: DataEngineRequest[], options?: { transaction?: boolean }): Promise<any[]>;
/**
* Execute raw command (Escape hatch)
*/
execute?(command: any, options?: Record<string, any>): Promise<any>;
}