Prerequisites
馃殌 Feature Proposal
Description
The exists method in common frameworks and implementation implies the same thing : a boolean (or promise that resolve to a boolean).
Changing the meaning of this function can be extremely misleading for everyone that will make assumptions, this change produce a breaking change (even if the value is "truthy").
Consider the snippet bellow, even if code like this may be extremely rare, its remains inconsistent syntactically :
const exists = await Model.exists({});
if (exists) {} // works
if (exists === false) {} // never trigger
if (exists === true) {} // never trigger
Proposition
I know the functionality provided by the new implementation is wanted, so bellow my proposition :
- revert the changes to this signature (as of
5.13.X version) :
prototype.exists({}): Promise<boolean>
- add a method to keep the
exists functionality :
prototype.findOneId({}) : Promise<{_id: ObjectId}|null>
Motivation
Keeping code consistent, understandable for anyone, with no misleading syntax or behaviours
Someone that doesn't know mongoose, should be able to read the code and understand it without documentation.
Example
No response
edit: typo
Prerequisites
馃殌 Feature Proposal
Description
The
existsmethod in common frameworks and implementation implies the same thing : a boolean (or promise that resolve to a boolean).Changing the meaning of this function can be extremely misleading for everyone that will make assumptions, this change produce a breaking change (even if the value is "truthy").
Consider the snippet bellow, even if code like this may be extremely rare, its remains inconsistent syntactically :
Proposition
I know the functionality provided by the new implementation is wanted, so bellow my proposition :
5.13.Xversion) :existsfunctionality :Motivation
Keeping code consistent, understandable for anyone, with no misleading syntax or behaviours
Someone that doesn't know mongoose, should be able to read the code and understand it without documentation.
Example
No response
edit: typo