hachoter
Explore posts from serversDTDrizzle Team
•Created by hachoter on 9/25/2024 in #help
Is there a way to reference multiple fields in a many to one relation?
I have this schema
I want
users.privateChats
to be a complete list of chats including ones where privateChats.userId
and privateChats.chatPartnerId
are the users id, I know for this particular example I should probably create a different data model but in my real example (which is over 100 lines so I won't share it) it's not really possible, is there any way to achieve this?1 replies
DTDrizzle Team
•Created by hachoter on 5/27/2024 in #help
Is it possible to batch update based on id?
I have a table with two columns id and position, I want to update the position based on the id, I am creating a list like this
And I want to update all records with the corresponding position, the only way I can think of is with an onConflict but for insert I need all the columns and I don't want to pass all that when the only data I need is id and position, is there a simpler way to do this?
1 replies
DTDrizzle Team
•Created by hachoter on 5/26/2024 in #help
has anyone managed to get drizzle to work with tauri sql plugin?
i believe they are using sqlx and I am not sure if it's the same as sqlite, I am currently working with this example I got off github
I am getting an error
subRows
is not defined when using the query API, is there a different adapter that might be better suited for this use case?2 replies
DTDrizzle Team
•Created by hachoter on 5/21/2024 in #help
Has anyone used drizzle with sql.js? how do I create migrations?
I am building a software that will run on the users browser using sql.js, has anyone used it with drizzle? I saw an example project in the drizzle repo but they are importing a sql file instead of migrations, I would rather run migrations using drizzle-kit or whatever is available
1 replies
DTDrizzle Team
•Created by hachoter on 1/5/2024 in #help
Cannot reference a table that references back to the first table
I am getting this typescript error
When I am trying to create a foreign key on one of the columns to a table that also has a foreign key constraint back the the
clubs
table, is this not allowed or is there a different way to do it?3 replies
DTDrizzle Team
•Created by hachoter on 1/3/2024 in #help
PostgresError: there is no unique constraint matching given keys for referenced table "table_name"
I am getting this error, I looked at the migration file and i cannot see anything that would cause this error, I am not referencing the table table_name anywhere other than creating foreign key constraints to the id of this table which exists so I am not sure how it would cause any errors
3 replies
DTDrizzle Team
•Created by hachoter on 10/26/2023 in #help
migrate function hangs without any result
I have this in my
migrate.js
file
when I run the file with bun everything hangs and nothing get's executed, the log functions log the correct credentials and file path but the execution stops after the migrate call, it hangs longer than the timeout so I don't think it is a database issue20 replies
DTDrizzle Team
•Created by hachoter on 10/15/2023 in #help
is there a way to create virtual columns in postgres?
I could just create a migration but I want the type to be correct, if it allows null it will be wrong and if it doesn't it will require it in inserts
1 replies
DTDrizzle Team
•Created by hachoter on 9/27/2023 in #help
Type cannot be inferred when using returning on insert
I have this function and it is causing typescript errors
res
is types correctly but I am getting this error
This is a simple project with no qorkspace, everything is installed in the same package13 replies
TTCTheo's Typesafe Cult
•Created by hachoter on 9/19/2023 in #questions
trpc client does not have a property query
I think this is an issue on my end here is how I am defining everything
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/trpc/server';
export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://127.0.0.1:4000/trpc'
})
]
});
```
But when I try to query like this client.assets.images.query I get an error property query does not exist, it correctly infers the type assets etc... but not query
This is an express/sveltekit project but I understand trpc does not need any special configuration for this
2 replies
Property 'query' does not exist on type ...
I think this is an issue on my end here is how I am defining everything
And in my client, I have this
But when I try to query like this
client.assets.images.query
i get an error property query does not exist, it correctly infers the type assets etc... but not query6 replies
DTDrizzle Team
•Created by hachoter on 8/4/2023 in #help
I need help generating a query for a schema
Hi guys I have the following schema
I want to create a single query that will generate something along the lines of this type
Basically I need to create a left join for manager, owner and employee and attach it to the correct key, I also need the user to include an array of emails and phone number (ideally already sorted by position) and join the profiles on top of that
The actual database schema is not for this type of data so the schema actually makes sense, I don't want to use rqb because I want to learn how to do something like this in sql as well
1 replies
DTDrizzle Team
•Created by hachoter on 8/3/2023 in #help
permission denied on insert
I have a drizzle user with full permissions set but I am getting permission denied errors, I have rls enabled
1 replies
DTDrizzle Team
•Created by hachoter on 8/2/2023 in #help
0 tables fetched when introspecting a postgres database
I granted all permissions to a drizzle user like this
But when I try to introspect with this connection string
I get this
It only fetches enums but no tables, I know there are tables and the user should have access to it
drizzle-kit v0.19.12
3 replies
DTDrizzle Team
•Created by hachoter on 6/27/2023 in #help
What is the type of transaction prop?
When creating a transaction I get this prop
I am trying to define a function like this
This way I can reuse the same functions with and without a transaction, I am having trouble typing the
Transaction
type, the type in vscode is a long complex type and I was wondering if there is some exported type I could use5 replies
DTDrizzle Team
•Created by hachoter on 6/26/2023 in #help
Is typescript slow for anyone else?
Typescript is incredibly slow for anything related to drizzle, I have an m1 macbook pro with decent memory so I don't think it's my machine, is anyone else experiencing this or is it unrelated to drizzle
6 replies
DTDrizzle Team
•Created by hachoter on 6/12/2023 in #help
What's the overhead (if any) of using the new relational api?
I love the new relational api but I am wondering about the performance overhead
10 replies
DTDrizzle Team
•Created by hachoter on 6/11/2023 in #help
I need some guidance on joins
Hi I am using joins because it makes the most sense in my application, I was gonna try out the relations api but I want to work on my sql skills as well, so I have this schema and I am trying to understand how to get all teh tables returned in a single query
here is the schema
I stripped all the extra columns so there might be a syntax error in there, sorry in advance
What I am trying to get is something like this
And of course all the other fields
So far I have this query which at least in typescript looks ok (my db is not set up so I can't test at the moment) but I don't know how to get the nested tables
I probably need another left join but where do I put that?
7 replies
DTDrizzle Team
•Created by hachoter on 5/29/2023 in #help
Maximum call stack exceeded with relation to self
I have the following table
I am running the following query
and I am getting a maximum call stack exceeded error, here is the full log
4 replies