piscopancer
piscopancer
Explore posts from servers
DTDrizzle Team
Created by K1|ller on 5/31/2024 in #help
alternative to supabase postgres and realtime?
try vercel storage, they support postgres
2 replies
DTDrizzle Team
Created by piscopancer on 6/4/2024 in #help
need postgres explanation
i want to move from sqlite to posgresql. Previously I did not need to use anything at all and stored my dev local.db in the root folder, now with postgres things got complicated. I cannot use local.db with postgres, or can I?
3 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
forget about union i spoke of above
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
it's literally a Promise.all but for sql queries
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
new solution is batch
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
@Sillvva no
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
@Sillvva oh my god. I have read some docs in drizzle and found out that you can combine absolutely unrelated queries using unions, and that is exactly what I need for two separate tables
import { union } from 'drizzle-orm/sqlite-core'
import { users, customers } from './schema'

const allNamesForUserQuery = db.select({ name: users.name }).from(users);

const result = await union(
allNamesForUserQuery,
db.select({ name: customers.name }).from(customers)
).limit(10);
import { union } from 'drizzle-orm/sqlite-core'
import { users, customers } from './schema'

const allNamesForUserQuery = db.select({ name: users.name }).from(users);

const result = await union(
allNamesForUserQuery,
db.select({ name: customers.name }).from(customers)
).limit(10);
you can find this example on their docs. damn I am so stupid, I would have already known that if I learned SQL in the first place instead of jumping straight into ORM totally missing any SQL knowledge
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
oh, do you mean i cannot query more than one table at once with query api atm? and i need to, let's say used Select api to query from more than 1 table
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
yes ofc it's possible, but this is too much data. my use case for this query is a user page with their stats and i need to display how many (literally a number) of questions they answered correctly, according to the questions creators
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
this errs right now
extras: (t) => ({
// a number of "answers" (table, see above) whose "authorId" === t.id
acceptedAnswers: acceptedAnswers(userId).as('accepted_answers'),
}),
extras: (t) => ({
// a number of "answers" (table, see above) whose "authorId" === t.id
acceptedAnswers: acceptedAnswers(userId).as('accepted_answers'),
}),
but i will try things
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
yeah but you know for sure it's bad and sql is designed to query whatever data you want, no matter its complexity at one call. that's my goal here
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
because i remember in drizzle you can compose Select api queries (provided by you) and Query api queries (my code)
21 replies
DTDrizzle Team
Created by piscopancer on 3/25/2024 in #help
count() for join tables in query API
ok and i assume i can also integrate this function right inside my extras, right?
21 replies
DTDrizzle Team
Created by piscopancer on 3/22/2024 in #help
"You're about to add not-null useless column without default value, which contains 1 items"
do you think this is an issue on the side of drizzle for generating FALSE and TRUE values in the migration for sqlite db?
6 replies
DTDrizzle Team
Created by piscopancer on 3/22/2024 in #help
"You're about to add not-null useless column without default value, which contains 1 items"
No description
6 replies
DTDrizzle Team
Created by piscopancer on 3/22/2024 in #help
"You're about to add not-null useless column without default value, which contains 1 items"
this is so weird
6 replies
DTDrizzle Team
Created by piscopancer on 3/18/2024 in #help
many-to-many foreign key constraint 787 issue
Not only I cannot add new rows, I cannot edit them either, it throws 787
4 replies
DTDrizzle Team
Created by piscopancer on 3/18/2024 in #help
many-to-many foreign key constraint 787 issue
* I double checked that primaryKey function comes from sqlite adapter
import { integer, primaryKey, sqliteTable, text, type SQLiteColumn } from 'drizzle-orm/sqlite-core'
import { integer, primaryKey, sqliteTable, text, type SQLiteColumn } from 'drizzle-orm/sqlite-core'
* userId and questionId are both primary keys
4 replies