-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document using virtuals. #23
Comments
@marshallswain Again, I think this is more of a documentation issue. If you are working with the mongoose model inside a hook you do have access to the virtuals. If you want virtuals included in your output I think you should have to specify that explicitly like you did above. That's really part of mongoose. |
@marshallswain thanks mate! |
Hi, The documentation about mongoose's virtuals is not more abailable. What is the suggested way to work virtuals? I've found that specfiyng lean = false and doing the aforementioned it makes this to work |
// Create a virtual field for id. schema.set("toJSON", { virtuals: true }); front end is ReactJS with Redux With this setup, I realize when i service().create() from client to server, the id is in the response. but when service().find() the id is not there, only _id I did most things accordingly, curious what's wrong or am i missing out anything? |
Solution ->>> The problem is the "lean" option in mongoose queries. Feathers.JS has lean = "true" as default (this can be easily seen in the "feathers-mongoose" codebase). More info: https://mongoosejs.com/docs/6.x/docs/api/query.html#query_Query-lean. solutions: |
Setting up a virtual currently does nothing to the output This is currently enabled separately in Mongoose using the following commands:
The text was updated successfully, but these errors were encountered: