-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom-objectql-example.ts
More file actions
44 lines (35 loc) · 1.29 KB
/
custom-objectql-example.ts
File metadata and controls
44 lines (35 loc) · 1.29 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
/**
* Example: Custom ObjectQL Instance
*
* This demonstrates how to use a custom ObjectQL instance with the kernel.
* This is useful when you have a separate ObjectQL implementation or need
* custom configuration.
*/
import { ObjectStackKernel, ObjectQLPlugin, ObjectQL } from '@objectstack/runtime';
import { InMemoryDriver } from '@objectstack/driver-memory';
(async () => {
console.log('🚀 Example: Custom ObjectQL Instance...');
// Create a custom ObjectQL instance with specific configuration
const customQL = new ObjectQL({
env: 'development',
// Add any custom host context here
customFeature: true,
debug: true
});
// You can also pre-configure the ObjectQL instance
// For example, register custom hooks
customQL.registerHook('beforeInsert', async (ctx) => {
console.log(`[Custom Hook] Before inserting into ${ctx.object}`);
});
// Create kernel with the custom ObjectQL instance
const kernel = new ObjectStackKernel([
// Register your custom ObjectQL instance
new ObjectQLPlugin(customQL),
// Add your driver
new InMemoryDriver(),
// Add other plugins and app configs as needed
]);
await kernel.start();
console.log('✅ Kernel started with custom ObjectQL instance');
console.log('ObjectQL instance:', kernel.ql);
})();