79246343

Date: 2024-12-03 05:23:20
Score: 1
Natty:
Report link

There is a mongoose plugin which can assist with this action.

Find or create plugin npm package

It provides a findOrCreate method that will either return the record, or create a new one. Very similar to how other ORM engines (Such as Laravel's eloquent) handles this type of operation.

I thought it might be nice to post an answer, so people are aware.

Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Cam