@Prop() schemaType on Map not working
Closed this issue · 3 comments
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Issue #413 is not yet fixed, even if it's marked as closed.
Because nobody reacted on the issue, that it is not solved, I opened this issue to notify you
Minimum reproduction code
n/a
Steps to reproduce
See #413
Expected behavior
Return a map type instead of an object
Package version
9.0.0
mongoose version
6.6.5
NestJS version
9.0.0
Node.js version
14.21.2
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).
I see, you cannot use raw
, which makes sense
any news about this topic?
I tried to make the same question in discord with no answer.
this is the question:
to store a { [key: string]: string }
object following the docs I've set my graphql field as
@Field(() => GraphQLJSON)
name: JSON;
(using JSON scalar) and on the schema the Mongoose Object is defined like
@Prop({ type: SchemaTypes.Mixed })
this is the only working configuration I've come up with, but this doesn't involve any type of schema validation.
I expected I could do something like @Prop({type:Map, of: String})
or @Prop(raw({type:Map, of: String}))
but I get casting error:
validation failed: name: Cast to Map failed for value "[Object: null prototype] (type object) at path because of "TypeError" nestjs mongoose
is this expected?