zhuguifei
2025-06-17 c1cc49dd93d38f51790558541d6835d1598ecccf
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
 * Preload module, this file will be loaded when the program starts.
 */
 
import { logger } from 'ee-core/log';
 
//import { crossService } from '../service/cross';
import { initDb } from  '../service/database'
// import { neDbManager } from '../service/database/NeDbManager'
 
async function preload(): Promise<void> {
  // Example feature module, optional to use and modify
  logger.info('[preload] load 5');
 
  // go server
  //crossService.createGoServer();
 
  // init sqlite db
  // 初始化数据库
  await initDb();
 
// // 插入数据
//   const userId = await db.insert('users', {
//     name: 'John Doe',
//     email: 'john@example.com',
//     age: 30
//   });
//   console.error(userId)
//
// // 查询所有用户
//   const allUsers = await db.findAll('users');
//   console.error(allUsers)
// // 查询单个用户
//   const user = await db.findOne('users', 'id = ?', [userId]);
//   console.error(user)
// // 更新用户
//   const updatedCount = await db.update('users', 'id = ?', {
//     name: 'John Smith',
//     age: 31
//   }, [userId]);
//   console.error(updatedCount)
 
// 删除用户
//   const deletedCount = await db.delete('users', 'id = ?', [userId]);
//   console.error(deletedCount)
 
 
  // 获取用户表
//   const userTable = dbManager.getTable<User>('users');
// // 创建索引
//   await userTable.ensureIndex({ fieldName: 'email', unique: true });
//
// // 插入用户
//   const newUser = await userTable.insert({
//     name: 'John Doe',
//     email: 'john@example.com',
//     age: 30
//   });
//
// // 查询用户
//   const users = await userTable.find({ age: { $gte: 18 } });
//   const user = await userTable.findOne({ email: 'john@example.com' });
//
// // 更新用户
//   await userTable.update(
//       { _id: newUser._id },
//       { age: 31 }
//   );
//
// // 删除用户
//   await userTable.remove({ email: 'john@example.com' });
 
}
 
/**
 * Entry point of the preload module
 */
export { preload };