Do you want to request a feature or report a bug?
Bug regarding the documentation.
What is the current behavior?
Multiple pages reference link to http://mongoosejs.com/docs/guide.html#safe, where the documentation for the safe
option is supposed to be, but the link does not work (the word safe
is not mentioned anywhere on that page and the anchor does not exist).
Example: http://mongoosejs.com/docs/api.html#schema_Schema
I currently cannot find out what the safe
option does.
What is the expected behavior?
The links should work and the option be documented.
Please mention your node.js, mongoose and MongoDB version.
mongoose docs: 5.1.6
For everyone else also looking for the documentation, here is an archived version: https://web.archive.org/web/20171219051408/http://mongoosejs.com:80/docs/guide.html#safe
Thanks for reporting, will fix. In general, the safe option is vestigial and shouldn't be used, you should use writeConcern instead.
@vkarpov15 Thank you!
However, I cannot find any documentation on the writeConcern
option. I want to set a different write concern for one of my schemas and so far I have done that by passing an object (e.g. {w: 'majority', j: true, wtimeout: 3000}
) to the safe
option. Is there a better way? If so, it would be great if that were documented properly.
Yeah this is definitely a significant gap in our docs. We'll fix this for the next release. The MongoDB writeConcern docs should be sufficient for now though, mongoose doesn't do anything special on top of MongoDB in terms of write concerns.
@vkarpov15 Thank you for listening to the community!
Also, would you please be so kind as to provide an example on how to properly pass a writeConcern to a schema? I'm confused.
Thank you very much in advance.
Right now we don't have support for writeConcerns in schemas, you need to specify writeConcern on your update queries. That's definitely a gap in our functionality, we will add that asap
@vkarpov15 Thank you, that's awesome! Once the commits are released, I'll switch from the safe
option to writeConcern
. :tada:
Changes were released with 5.2.3 :tada: Here are the writeConcern
schema option docs and the query helpers for setting w
, j
, and wtimeout
on individual queries.
@vkarpov15 Thank you so, so much! :tada:
Most helpful comment
Right now we don't have support for writeConcerns in schemas, you need to specify writeConcern on your update queries. That's definitely a gap in our functionality, we will add that asap