shihuojian commited on
Commit
b0ac1c0
·
1 Parent(s): 6c69907

修改插件注入mongodb bug

Browse files
ndcc/server/lib/basic.js CHANGED
@@ -22,7 +22,7 @@ module.exports = class{
22
 
23
  this.ctx = {
24
  plugins:route.settings.plugins || {}, //替换为注入插件
25
- db:(collection,options={})=>mongodb(request,collection,options),
26
  user:!_.isEmpty(user) ? {_id:user._id,name:user.username,source:user.source} : user,
27
  cache,
28
  id:ToBase64(id),
 
22
 
23
  this.ctx = {
24
  plugins:route.settings.plugins || {}, //替换为注入插件
25
+ db:(collection,options={})=>mongodb(inject ? inject.request : request,collection,options),
26
  user:!_.isEmpty(user) ? {_id:user._id,name:user.username,source:user.source} : user,
27
  cache,
28
  id:ToBase64(id),
src/pages/api/plugins/Zi34RUP5T5YuGLrJ.js CHANGED
@@ -3,7 +3,7 @@
3
  export default async (req)=>{
4
  const {send,reply,error,isGet,db,cookie,event,socket} = await req.ctx();
5
  try{
6
- send('testPlugin12s')
7
  }catch (e){
8
  error(e)
9
  }
 
3
  export default async (req)=>{
4
  const {send,reply,error,isGet,db,cookie,event,socket} = await req.ctx();
5
  try{
6
+ send(await db('test').findOne())
7
  }catch (e){
8
  error(e)
9
  }