bun:sqlite FindFirst returns an object with all values undefined
Running FindFirst gives me an object with the proper keys but all values are undefined. Running FindMany with a limit of 1 gives me the correct output but in an array.
Enabling logger gives this output for both findFirst and findMany with limit 1
select "id", "name", "location" from "company" limit ? -- params: [1]
I've narrowed it down by doing db.query.company.findFirst().prepare();
with this i can then do both .get()
and .all()
, it seems using get gives me the broken output while doing all give me the array with correct output.
Any ideas what is happening here and why?5 Replies
You should use
.get()
when you're expecting only one value from the database. The problem is that findFirst is also attempting to pull the first element of the array.
Does it work is you use findMany
with limit 1
and the then .get()
?
findFirst
with .all()
should also work I thinkMy intention is not to use the
.get()
or .all()
but rather that they seem to be the underlaying functions being called and somewhere in the code for get in combination with bun:sqlite (i think) it breaks and I get an object with the correct keys but undefined values.
For now this is my workaround to emulate the correct behaviour with findFirst Please create an issue in GH and if you can include the code that's giving you problems
Will do, thanks!
Is there any prefered online codespace I should submit with or just a codeblock?
Preferably a repo or a code sandbox