问题描述
const anotherModel = require(__dirname + "/anotherModel.js")
const mongoose = require("mongoose")
let injectPlugin = async (schema,options) => {
const anotherObject = await anotherModel.findOne({name: options['anotherModelName'] }).lean();
schema.methods.testfunction = async () => {
console.log(anotherObject)
}
}
module.exports = injectPlugin
在上面显示的示例代码段中,我尝试初始化和加载另一个模型,并将数据用于插件中的后续操作。
TypeError: sampleEntity.testfunction is not a function
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)