I seem to be facing an issue with my schema setup. I have defined a base/parent Schema and 3 children schemas, but I am encountering an error message that says:
No overload match this call
Below is the structure of my schema:
import { model, Schema } from 'mongoose';
export interface IBaseCriteria {}
const baseOptions = {
discrimatorKey: 'itemType',
collection: 'criterias',
};
const baseCriteriaSchema = new Schema<IBaseCriteria>({
baseOptions,
});
export default model<IBaseCriteria>('BaseCriteria', baseCriteriaSchema);
import { model, Schema } from "mongoose";
import BaseCriteria from "./baseCriteria.model";
export interface IDateCriteria {
after: Date;
before: Date;
}
const dateCriteria = BaseCriteria.discriminator(
"date",
new Schema({
after: { type: Date },
before: { type: Date },
})
);
export default model("DateCriteria", dateCriteria);
I can't figure out what mistake I may have made. Any suggestions on how to resolve this?