db.get vs db.find
I know its probably a bit late now as its likely the API is now fixed but a convention I really like is "get" means the thing you are looking for MUST be there whereas "find" could return the thing OR undefined.
So in this case it would have been great if we had both
db.get
AND db.find
where the latter is basically what db.get
currently is and the new db.get
throws an error if it cant find the entry.
Alternative you could do the Prisma route with its orThrow
convention to have something like db.getOrThrow
.
Anyways, I just thought I would put it out there 🙂1 Reply
You're right that we can't change how db.get behaves (it's too much change to force on developers probably even in a semver breaking release) but getOrThrow and mustGet are possibilities here. Appreciate hearing this!