Reputation: 723
I'm trying to do something like this:
let Token = mongoose.model("Token", InToken)
let add = () => {
return 1 + 1
}
module.exports = {
Token,
add
}
Whenever I do this, I receive this error: TypeError: Token is not a constructor
.
How can I export the model along with other objects?
Upvotes: 0
Views: 114
Reputation: 1914
You should import Token like this:
const { Token } = require("path to token model");
Upvotes: 0
Reputation: 36964
When you import your module with
const Something = require('./Something'); // contains the file in your question
you will be able to use new
with:
const token = new Something.Token()
Upvotes: 1