Gary, el Pingüino Artefacto
Gary, el Pingüino Artefacto
Explore posts from servers
DTDrizzle Team
Created by san4d on 4/11/2024 in #help
Parameterized Interval in Where Clause
:c
4 replies
DTDrizzle Team
Created by san4d on 4/11/2024 in #help
Parameterized Interval in Where Clause
Hi dude, did you manage to get this working?
4 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
I tried mapping with extras props and the sql tag, but I read on github that there is a bug there the .mapWith is not called on extra props
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
I tried this way but it doesn't work with the query API
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
Also could something like
export const usersTable = pgTable("users", {
// Possible?
id: uuid().primaryKey().transform((value) => `users_${value}`),
createdAt: timestamp().notNull().defaultNow(),
givenName: varchar({ length: 64 }).notNull(),
familyName: varchar({ length: 64 }).notNull(),
})
export const usersTable = pgTable("users", {
// Possible?
id: uuid().primaryKey().transform((value) => `users_${value}`),
createdAt: timestamp().notNull().defaultNow(),
givenName: varchar({ length: 64 }).notNull(),
familyName: varchar({ length: 64 }).notNull(),
})
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 10/14/2024 in #help
Applying drizzle migrations on Vercel with Hono
After some hours, I managed to solve it. For anyone with the same issue, use the path module.
const folder = path.join(process.cwd(), "src", "databases", "tenants", "migrations")
const folder = path.join(process.cwd(), "src", "databases", "tenants", "migrations")
I also added this on the next.conf, Idk if it is necesary but xd
experimental: {
outputFileTracingIncludes: {
"/api/hono/[[...routes]]": ["./src/databases/tenants/migrations/**/*"],
"/api/hono/tenants/create": ["./src/databases/tenants/migrations/**/*"],
},
},
experimental: {
outputFileTracingIncludes: {
"/api/hono/[[...routes]]": ["./src/databases/tenants/migrations/**/*"],
"/api/hono/tenants/create": ["./src/databases/tenants/migrations/**/*"],
},
},
and
webpack: (config, { isServer }) => {
if (isServer) {
if (process.env.VERCEL_ENV === "production") {
execSync(`curl -X GET ${process.env.VERCEL_URL}/api/hono/tenant/create`)
}
}
return config
},
webpack: (config, { isServer }) => {
if (isServer) {
if (process.env.VERCEL_ENV === "production") {
execSync(`curl -X GET ${process.env.VERCEL_URL}/api/hono/tenant/create`)
}
}
return config
},
2 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 6/3/2024 in #help
Helpers for querying in the new PostGIS Geometry type
they don't
3 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 4/30/2024 in #help
Filtering a jsonb with the shape Array<{id:string,name:string}>
I ended up using this workaround, may be there is a better way
async function getPostsByTagIds(tagIds: string[]) {
const ids = z.string().uuid().array().parse(tagIds)
const obj = JSON.stringify(ids.map((id) => ({ id })))
return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> '${sql.raw(obj)}'`
)
}
async function getPostsByTagIds(tagIds: string[]) {
const ids = z.string().uuid().array().parse(tagIds)
const obj = JSON.stringify(ids.map((id) => ({ id })))
return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> '${sql.raw(obj)}'`
)
}
4 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 4/30/2024 in #help
Filtering a jsonb with the shape Array<{id:string,name:string}>
This doesn't work btw
async function getPostsByTagIds(tagIds: string[]) {
const ids = '[{"id": "098b9acb-694d-4c00-b87f-64f9811f8810"},{"id":"46bba9b2-9b50-4e70-9284-6cddb2fe32d4"}]'
return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> ${ids}`
)
}
async function getPostsByTagIds(tagIds: string[]) {
const ids = '[{"id": "098b9acb-694d-4c00-b87f-64f9811f8810"},{"id":"46bba9b2-9b50-4e70-9284-6cddb2fe32d4"}]'
return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> ${ids}`
)
}
4 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 4/30/2024 in #help
Filtering a jsonb with the shape Array<{id:string,name:string}>
Idea:
async function getPostsByTagIds(tagIds: string[]) {

/*
Parameterize '[{"id": "098b9acb-694d-4c00-b87f-64f9811f8810"},{"id":"46bba9b2-9b50-4e70-9284-6cddb2fe32d4"}]'
Into something like:
const filter = `[${tagIds.map(id => ({ id }))}]`
*/

return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> SOME MAGIC HERE`
)
}
async function getPostsByTagIds(tagIds: string[]) {

/*
Parameterize '[{"id": "098b9acb-694d-4c00-b87f-64f9811f8810"},{"id":"46bba9b2-9b50-4e70-9284-6cddb2fe32d4"}]'
Into something like:
const filter = `[${tagIds.map(id => ({ id }))}]`
*/

return await db
.with(postsQuery)
.select()
.from(postsQuery)
.where(
sql`${postsQuery.tags} @> SOME MAGIC HERE`
)
}
4 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 3/3/2024 in #help
sql operator with array of strings
this one worked, thanks solo 😄
4 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 3/3/2024 in #help
sql operator with array of strings
This is the error: PostgresError: operator does not exist: text[] @> record
4 replies
DTDrizzle Team
Created by James on 1/17/2024 in #help
Extract type from SubQuery
😄
24 replies
DTDrizzle Team
Created by James on 1/17/2024 in #help
Extract type from SubQuery
which version of drizzle are you using?
24 replies
DTDrizzle Team
Created by James on 1/17/2024 in #help
Extract type from SubQuery
No description
24 replies
DTDrizzle Team
Created by James on 1/17/2024 in #help
Extract type from SubQuery
hi, i was casually trying to steal this code and noticed some unknown types
24 replies
DTDrizzle Team
Created by jakeleventhal on 1/3/2024 in #help
How to get the count of relations?
are there any plans for managing this with relational queries? if it is possible of course
37 replies