bwgjoseph / mongoose-vs-ottoman

feature comparison between mongoose and ottoman
0 stars 1 forks source link

discrepancy between findById and findOne returns #56

Closed bwgjoseph closed 3 years ago

bwgjoseph commented 3 years ago

Hi,

When using findById and if the document does not exist, it (by right) throws a DocumentNotFoundError: document not found (see #55)

However, when using findOne, the documentation says that (and it does) return as null when the document is not found (see findOne)

I have yet to test for the other find* methods.

Is it intentional for it to return differently, or should it be consistent in the response across all the find* methods?


Update: findOneAndUpdate also throws document not found error when unable to match the fitler

AV25242 commented 3 years ago

should be fixed in the next release

AV25242 commented 3 years ago

Please check out alpha.22

bwgjoseph commented 3 years ago

Have verified that findOne returns is consistent with the others but the docs has yet to be updated and is currently still reflecting as returning null

Should it be tracked in here and close after the doc is updated? Or do you have another place that tracks for this particular doc update?

AV25242 commented 3 years ago

let me check with the team @bwgjoseph

bwgjoseph commented 3 years ago

Just saw that the doc is not updated

See https://v2.ottomanjs.com/guides/model.html#querying

User.findOne({ name: 'Jane' });
// will return a document with a User with the name "Jane" or null in case of not finding it

Doesn't match with code

image

AV25242 commented 3 years ago

@bwgjoseph correct me if I have mistaken, but this ticket awaits only doc updates at the moment ? if thats true then can you move the issue under doc ticket we have please? and close this ticket. If otherwise please let me know

bwgjoseph commented 3 years ago

That's correct.