-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathseed.ts
More file actions
63 lines (50 loc) · 1.66 KB
/
seed.ts
File metadata and controls
63 lines (50 loc) · 1.66 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
52
53
54
55
56
57
58
59
60
61
62
63
/**
* ObjectQL
* Copyright (c) 2026-present ObjectStack Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { ObjectQL } from '@objectql/core';
import { SqlDriver } from '@objectql/driver-sql';
import { ObjectLoader } from '@objectql/platform-node';
import * as path from 'path';
async function main() {
console.log("🚀 Starting Project Tracker Showcase...");
const app = new ObjectQL({
datasources: {
default: new SqlDriver({
client: 'sqlite3',
connection: { filename: ':memory:' },
useNullAsDefault: true
})
}
});
const loader = new ObjectLoader(app.metadata);
await loader.load(path.join(__dirname));
await app.init();
console.log("✅ Schema loaded from filesystem");
const ctx = app.createContext({ isSystem: true });
console.log("Creating Project...");
const project = await ctx.object('projects').create({
name: 'Website Redesign',
status: 'planning',
start_date: new Date()
});
console.log("Creating Task...");
const projectId = project._id || project.id;
await ctx.object('tasks').create({
name: 'Design Mockups',
project: projectId,
completed: false
});
console.log("Querying Tasks...");
const tasks = await ctx.object('tasks').find({
filters: [['project', '=', projectId]]
});
console.log("📊 Project Report:", JSON.stringify({ project, tasks }, null, 2));
}
if (require.main === module) {
main().catch(console.error);
}
export * from './types';