stupid question 2: get key types of nested object in mongoose, not ref/subcollections
See original GitHub issueTake this example:
@prop({ default: {}, _id: false })
openid: OpenId;
where OpenId is another class like this:
export class OpenId {
@prop({ index: true, sparse: true, unique: true })
google?: string;
@prop({ index: true, sparse: true, unique: true })
microsoft?: string;
@prop({ index: true, sparse: true, unique: true })
apple?: string;
}
But then when for example when trying to update an object with mongoose saying:
manager.findByIdAndUpdate(_id, {
openid.google: "something"
});
will throw an error as it doesn’t tell you what keys you have on the “openid” object.
Is it possible to get the types right there without having to work with populating refs/subcollections?
I have worked in the past with proper subcollections & refs and that’s fine for that use case, but sometimes you just need a plain nested object.
Is this supposed to work or am I just doing things wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Mongoose: Schema for nested Json and store it (Node.js)
For a nested JSON, you can do something like this: var mongoose =require('mongoose'); var Schema = mongoose.Schema; var standardmessage ...
Read more >4/4: Using MongooseJS to push objects onto sub-arrays
Let's wrap it up by saving the student events in the database!0:33 Q: what to do without help? A: google it!5:30 why mongoose8:38...
Read more >How to change the boolean value in nested object - Mongoose
Hello, I want to be able to change the value of a step for goal and step Id that is passed in through...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For my curiosity, could you offer the actual error message?
Scott
closing because this question seems to be answered