tegg
tegg copied to clipboard
Service 里面怎么拿到context
在此输入你需要反馈的 Bug 具体信息(Bug in Detail):
Service 里面怎么拿到context
@SingletonProto({ // 如果需要在上层使用,需要把 accessLevel 显示声明为 public accessLevel: AccessLevel.PUBLIC, }) export class DemoService { constructor(){ setInterval(() => { //执行定时任务 // 调用egg-sequelize model更新数据库 ctx.model.Demo.findAll(); }, 100000); } }
可复现问题的仓库地址(Reproduction Repo)
https://github.com/ssss
Node 版本号:
v20.14.0
TEgg 版本号:
3.5.2
相关插件名称与版本号:
"egg-sequelize": "^6.0.0",
操作平台与版本号:
macos 15.1
egg-sequelize 目前还没有适配 tegg,可以先看看 https://github.com/eggjs/tegg/blob/master/plugin/orm/README.md
在controller层传参过来,声明参数@Context() ctx: EggContext, 传给service