Closed ralyodio closed 2 years ago
You should use all
/allEntries
, which will return an empty array if no rows are found. Although it might be worth considering changing one
to return null if the entry is not found, and only throw if there are more than one entry?
Although it might be worth considering changing
one
to return null if the entry is not found, and only throw if there are more than one entry?
@dyedgreen I think this would help in avoiding a lot of currently needed try...catch
. Do you have plans to implement the change?
We’d probably want to make it first
instead, so we can be backwards compatible. But this would be a relatively simple PR. Do you want to have a go at it @jsejcksn? 😊
We’d probably want to make it
first
instead, so we can be backwards compatible. But this would be a relatively simple PR. Do you want to have a go at it @jsejcksn? 😊
@dyedgreen I'm not familiar with the source, but I'll take a look. Should I create a draft PR to establish a place for communication if I begin and have questions?
Sounds good 😊
Maybe as a side-note: Such a function would simply be a slightly more efficient way to do this:
const [first] = myQuery.all();
This throws an error if no rows are found:
How can I handle this error and just return null?