'NestJS model modelling, problem when sending HTTP request
Im trying to send a POST-request with my nestJS application. I have made the following model structure:
const WishlistSchema = new mongoose.Schema({
productID: { type: Number, required: true, unique: true },
})
export const VisitorSchema = new mongoose.Schema({
visitorID: { type: Number, required: true, unique: true },
wishlist: [WishlistSchema],
})
interface Wishlist {
productID: number;
}
export interface Visitor {
visitorID: number;
wishlist: Types.DocumentArray<Wishlist>;
}
When I try to send a POST-request in postman like this:
{
"visitorID": 123123,
"productID": 3123123
}
I get the following error message "Visitor validation failed: wishlist: Cast to embedded failed for value "3123123" (type string) at path "wishlist""
Anyone that know where my mongoose schema is wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
