desert
desert
Explore posts from servers
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
ok thank you!
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
ahhh thank you. Do you know if this is a feature that is planned for the future or not?
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
every asset has one assetModeration, i want to filter out assets that do not have assetModeration.state === "accepted"
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
i did not mean to filter the relationship, i did not understand well how to use relational queries, what i want to do is to filter every asset for which its moderation is not accepted, i want to filter the top layer table
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
yes sure, here it is:
export const assets = pgTable(
'assets',
{
id: serial('id').primaryKey(),
created_at: timestamp('created_at').notNull().defaultNow(),
description: text('description').notNull(),
priceCents: integer('price_cents').notNull(),
name: text('name').notNull(),
assetCategoryId: integer('asset_category_id').notNull(),
authorId: text('author_id').notNull(),
thumbnailUrl: text('thumbnail_url'),
thumbnailKey: text('thumbnail_key'),
moderationId: integer('moderation_id').notNull(),
assetFileKey: text('asset_file_key').notNull().unique(),
assetFileUrl: text('asset_file_url').notNull(),
},
(t) => ({
unq: unique().on(t.name, t.authorId)
})
)
export const assets = pgTable(
'assets',
{
id: serial('id').primaryKey(),
created_at: timestamp('created_at').notNull().defaultNow(),
description: text('description').notNull(),
priceCents: integer('price_cents').notNull(),
name: text('name').notNull(),
assetCategoryId: integer('asset_category_id').notNull(),
authorId: text('author_id').notNull(),
thumbnailUrl: text('thumbnail_url'),
thumbnailKey: text('thumbnail_key'),
moderationId: integer('moderation_id').notNull(),
assetFileKey: text('asset_file_key').notNull().unique(),
assetFileUrl: text('asset_file_url').notNull(),
},
(t) => ({
unq: unique().on(t.name, t.authorId)
})
)
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
the only thing that comes to my mind that could be causing this is that every column of this table is optional, when inserting i leave the values blank, most of them have defaults
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
ok I'm updating, trying again in a minute! thank you for the help btw <3
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
should i npm update? i saw a new version got released today
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
one asset -> one assetModeration
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
thats it, its a one on one relationship
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
export const assetsRelations = relations(assets, ({one, many}) => ({
assetModeration: one(assetsModerations, {fields: [assets.moderationId], references: [assetsModerations.id]})
}))
export const assetsRelations = relations(assets, ({one, many}) => ({
assetModeration: one(assetsModerations, {fields: [assets.moderationId], references: [assetsModerations.id]})
}))
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
thank you! i'm sending them now
35 replies
DTDrizzle Team
Created by desert on 8/20/2023 in #help
Nested where clauses in relational queries
unfortunately it does not work, it just says 'where' property does not exist on assetsModerations
35 replies
DTDrizzle Team
Created by desert on 8/21/2023 in #help
Using query builder with views
thank you @Andrew Sherman
4 replies