desert
desert
Explore posts from servers
DTDrizzle Team
Created by desert on 9/11/2023 in #help
Error using relational queries but not with core queries
when i do
const invitesData = await db.select().from(invites).innerJoin(members, eq(invites.inviterId, members.id)).where(eq(invites.invitedId, user.id));
const invitesData = await db.select().from(invites).innerJoin(members, eq(invites.inviterId, members.id)).where(eq(invites.invitedId, user.id));
everything works as intended, but when I do
const invitesData = await db.query.invites.findMany({
with: {
inviter: true
},
where: eq(invites.invitedId, user.id),
})
const invitesData = await db.query.invites.findMany({
with: {
inviter: true
},
where: eq(invites.invitedId, user.id),
})
it gives me: PostgresError: column "invites.created_at" must appear in the GROUP BY clause or be used in an aggregate function relationships:
export const usersRelations = relations(users, ({many}) => ({
members: many(members),
invites: many(invites),
}))

export const invitesRelations = relations(invites, ({one}) => ({
inviter: one(members, {
fields: [invites.inviterId],
references: [members.id],
}),
invited: one(users, {
fields: [invites.invitedId],
references: [users.id],
})
}))

export const membersRelations = relations(members, ({many, one}) => ({
invites: many(invites),
}))
export const usersRelations = relations(users, ({many}) => ({
members: many(members),
invites: many(invites),
}))

export const invitesRelations = relations(invites, ({one}) => ({
inviter: one(members, {
fields: [invites.inviterId],
references: [members.id],
}),
invited: one(users, {
fields: [invites.invitedId],
references: [users.id],
})
}))

export const membersRelations = relations(members, ({many, one}) => ({
invites: many(invites),
}))
Thank you in advance <3
1 replies
DTDrizzle Team
Created by desert on 8/21/2023 in #help
Using query builder with views
How do you use the query builder with views? typescripts yells at me saying that db.query.nameOfView is not defined. Thank you in advance
4 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
I have this query: const asset = await db.query.assets.findFirst({ with: { assetImages : true, assetModeration: { where: eq(assetsModerations.state, "ACCEPTED"), //this line gives error columns: { state: true, }, } }, where: (eq(assets.id, id)) }) that gives this error: Object literal may only specify known properties, and 'where' does not exist in type ... the assetsModerations table looks like this: export const assetsModerations = pgTable( "assets_moderations", { id: serial('id').primaryKey(), created_at: timestamp('created_at').notNull().defaultNow(), description: text('description'), moderatorId: text("moderator_id").references(() => users.id), updatedAt: timestamp('updated_at'), state: moderationState('moderation_state').notNull().default('PENDING') } ) this error is not given if i try to do the same with assetImages, the other table, what is the problem here? Thank you in advance.
35 replies
TTCTheo's Typesafe Cult
Created by desert on 8/18/2023 in #questions
UploadThing error: Call unsuccessful when using useUploadThing and startUpload
I am using startUpload in a next client component, when I do the server logs this error: - ┌ POST /api/uploadthing?actionType=upload&slug=imageUploader 200 in 5571ms │ └──── POST https://uploadthing.com/api/prepareUpload 200 in 5460ms (cache: MISS) [UT] Call unsuccessful after 6 tries. Retrying in 32 seconds... Can someone help me? thank you in advance.
2 replies