In my models/user.js
file:
var mongoose = require(\'mongoose\');
var Schema = mongoose.Schema;
var userSchema = new Schema({
(define schema
I was making a different mistake like I have created the Schema but the issue was that I didn't use schema model (for insert, update, read and delete the doc).
i.e. I have created the collection something like that:
const playerSchema = new Schema({
bowling: {
style: String,
arm: String,
}
})
export const PlayerSchema = model('Player', playerSchema)
but didn't use or call PlayerSchema
model somewhere that's why I was getting this error.