I'm struggling to devise a Mongo Schema using nestjs/mongoose
decorators based on the structure of the class below:
@Schema()
export class Constraint {
@Prop()
reason: string;
@Prop()
status: Status;
@Prop()
time: number;
}
The challenge lies in the definition of Status
, which looks like this:
export type Status = boolean | 'pending';
I'm having difficulty determining what to pass to the prop
decorator for the status
attribute, as I keep encountering the following error message:
Error: Cannot determine a type for the "Constraint.status" field (union/intersection/ambiguous type was used). Make sure your property is decorated with a "@Prop({ type: TYPE_HERE })" decorator
Using { type: Status }
doesn't resolve the issue because Status
is a type
, not a Class
.