我正在尝试做这样的事情:
let Token = mongoose.model("Token", InToken)
let add = () => {
return 1 + 1
}
module.exports = {
Token,
add
}
每当我这样做时,我都会收到此错误:TypeError: Token is not a constructor
。
如何将模型与其他对象一起导出?
当您使用
const Something = require('./Something'); // contains the file in your question
您将能够将new
与:
const token = new Something.Token()
你应该像这样导入令牌:
const { Token } = require("path to token model");