/**
|
* 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 };
|