EDIT: My code here is correct, as is the answer I received. I realized after posting and getting an answer that the error was coming from another file not posted here. I'm posting this edit because I don't want to delete.
I'm quite sure I'm importing a schema, but for some reason it's being interpreted as a Model and I'm getting this Invalid Schema Configuration error. Here's the schema that's getting imported:
user.js:
const mongoose = require('mongoose');
let Schema = mongoose.Schema;
const userSchema = new Schema({
name: { type: String, required: true },
email: { type: String, required: true },
//eventsUpdated: [Schema.ObjectId], // ids of events updated
//flags: [Schema.ObjectId], // ids of flags of events
});
const user = mongoose.model('user', userSchema);
module.exports = user;
And here's the file that's importing: flag.js:
const mongoose = require('mongoose');
let Schema = mongoose.Schema;
const userSchema = require('./user').schema;
const flagSchema = new Schema({
field: String,
count: Number,
IPs: [String],
lastCleared: Date,
clearedBy: [userSchema]
});
const flag = mongoose.model('flag', flagSchema);
module.exports = flag;
I've tried importing different ways, like explicitly exporting only the userSchema in user.js, and nothing has solved it or even given a different error. I've tried solutions offered by similar questions like this one. Please help, and thank you!