accessing results of a select

I am confused. Based on this docs https://orm.drizzle.team/docs/crud this here
const todos = await db
.select({
id: todosTable.id,
completed: todosTable.completed,
description: todosTable.description,
title: todosTable.title,
})
.from(todosTable);
console.log(todos);
const todos = await db
.select({
id: todosTable.id,
completed: todosTable.completed,
description: todosTable.description,
title: todosTable.title,
})
.from(todosTable);
console.log(todos);
todos should be an array of objects. But it seems to be
SQLiteSelect {
_: {
selectedFields: {
id: [SQLiteInteger],
completed: [SQLiteInteger],
description: [SQLiteText],
title: [SQLiteText]
}
},
config: {
...
SQLiteSelect {
_: {
selectedFields: {
id: [SQLiteInteger],
completed: [SQLiteInteger],
description: [SQLiteText],
title: [SQLiteText]
}
},
config: {
...
What am I missing?
7 Replies
tcurdt
tcurdtOP17mo ago
Seems like docs are missing an .all()? But how would that work with insert and returning?
tcurdt
tcurdtOP17mo ago
It seems there is on open ticket about this https://github.com/drizzle-team/drizzle-orm/issues/815
GitHub
[BUG]: Undocumented - SQLite requires .run() to commit inserts · ...
What version of drizzle-orm are you using? 0.27.0 What version of drizzle-kit are you using? 0.19.2 Describe the Bug Running an .insert while using SQLite3 (via better-sqlite3) doesn't do anyth...
tcurdt
tcurdtOP17mo ago
Here is more info about it https://discord.com/channels/1043890932593987624/1131653827104350258 TLDR: For now it's a documentation bug. For now the API for sqlite is different. This may or may not change.
charlesbcraig
charlesbcraig16mo ago
Wow I just spent hours trying to figure out why my code wasn’t returning any results! Can’t believe this is still not fixed in the docs.
Andrii Sherman
Andrii Sherman16mo ago
It's fixed already, we just made sqlite api avalable without .run/.all/.. methods simple await will work
charlesbcraig
charlesbcraig16mo ago
I switched over to Neon before I found out, but I did see the announcement about the SQLite update!
Andrii Sherman
Andrii Sherman16mo ago
Sorry for a late response!
Want results from more Discord servers?
Add your server