I have a post
schema:
@Schema({ timestamps: true })
class PostDocument extends Document {
@Prop()
title: string;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Category' })
categoryName: Category
}
And when I am trying to save the data, I am getting error:
cast to objectid failed for value type string
Request data:
title: "Test"
categoryName: "test"