DT
Drizzle Teamitsanameidk

Generate Random UUID Sqlite

Hey i was wondering how i would create a unique ID that contains a random string of characters for a text?
model User {
id String @id @default(uuid())
}
model User {
id String @id @default(uuid())
}
Something like this but instead of mysql and primsa. Have Sqlite and Drizzle
Revan
Revan191d ago
I use nodejs randomuuid:
id: text("id", { length: 36 }).primaryKey().$defaultFn(() => randomUUID()),
id: text("id", { length: 36 }).primaryKey().$defaultFn(() => randomUUID()),
I dont believe sqlite has uuid generating functionality built in
Trader Launchpad
Trader Launchpad191d ago
Hey this is great, thank you. Does this work with expo/react native
itsanameidk
itsanameidk191d ago
when doing drizzle-kit generate:sqlite --out ./drizzle/migrations --breakpoints --schema=./drizzle/schema.ts it should of generated a default in the sql file instead of this right?
CREATE TABLE `applications` (
`id` text(36) PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
CREATE TABLE `applications` (
`id` text(36) PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
Revan
Revan191d ago
no I would assume no because the randomuuid function is part of the nodejs code, maybe there is a polyfill for node libraries for react native, or react native could have its own cryptography module that you could use
Trader Launchpad
Trader Launchpad191d ago
I’m trying to figure out a monorepo app with nextjs and expo, utilizing uuid in tables with SQLite. I don’t particularly want to manage 2 separate systems for creating and possibly decoding uuids, hopefully stored in binary format, on nextjs and expo. On MySQL I can use database uuid to standardize, but with SQLite I’m trying to find the best option
Trader Launchpad
Trader Launchpad190d ago
No description
Want results from more Discord servers?
Add your server
More Posts
Logging query timeIs it possible to log query time? I see that the current logger implementation sends the sql and the[How To?] Generate uuids properly on cloudflare d1 sqlite...I am running an app with Drizzle, TRPC, and Cloudflare D1 sqlite database: My initial project databDropping primary keys every timeso latest drizzle-kit fixed a bunch of issues with dropping indexes and preserving pk order but it'need help abstracting a functionThis may be an easy answer but how can I implement the following type? ```typescript export const Does drizzle support `disconnect` relations ?Does drizzle support `disconnect` feature on relations during update query similar to prisma ?binary columns in drizzle studioI have implemented the following custom type for storing blockchain addresses: ```typescript const aAccess values in "where" queryHey, so I wan't to do some calculations, specifically geo radius. How can I access the data while doUnable to delete from many to many relationship due to FK constraintI have the following schema, `Users` <> `Teams` - many to many usersOnTeams - table to hold this rPostgresError: Relation X does not exist - After reorganizing schemaHi guys, I have two tables (team and team_members) , which have a relation. All my schema was in onhow to do the opposite of inArray()?i'm getting all collections (music single, ep, or album) that contain a certain tag. currently i'm dHow to use drizzle-zod generated schemas in Next.JS frontend?I'm currently using the pages dir in Next.JS and I have a function making an API call. I want to pasTypeError: client.unsafe is not a function with neoni get this error only when using the neon driver. with normal postgres, it works normally.Getting "never" type from querying a relationWhen I use query function with "with" on a one to many relation it returns the type "never". What ammapWith, any special things to make it work ?I can't seem to have mapWith() work - I am logging inside the function and it nvever gets called. IWhy truncate??Updating some schemas. All 48 records in the item table have cmsSlug and cmsId. All 48 records have error on push on local libsqlI'm trying to use libsql locally, so i configure my drizzle.config.ts and when i try to run the pushDrizzle kit migration doesn't reflect schema's relationsI have two schemas in my application, one for parent courses and another one for child courses; theySQL string does not contain any statementI currently have 1 sqliteTable on my schema and 1 migration, so I wan't to create a new table and miCannot read properties of undefined (reading 'referencedTable')i'm just playing around with queries and i can't get this to work:```js const liked = await db.queryKey columns "user_id" and "id" are of incompatible types: text and bigint.I'm getting the error in the title ^ but they're the same type. ```js export const usersTable = pgT