Marťafiixek
Marťafiixek
DTDrizzle Team
Created by Marťafiixek on 6/6/2024 in #help
Dynamic column name and insert
Hi, how can I work with dynamic column names? I woud love to be able to do the following:
export const insertMultipleToJoinTable = async (
media: number[],
table: PgTable,
column: PgColumn,
entityId: number,
REDACTED: number | null,
REDACTED: number | null
) => {
await Promise.all(
media.map(async (mediaId) => {
await db.insert(table).values({
[column.name]: entityId,
mediaId,
})

await REDACTED(mediaId, REDACTED, REDACTED)
})
)
}
export const insertMultipleToJoinTable = async (
media: number[],
table: PgTable,
column: PgColumn,
entityId: number,
REDACTED: number | null,
REDACTED: number | null
) => {
await Promise.all(
media.map(async (mediaId) => {
await db.insert(table).values({
[column.name]: entityId,
mediaId,
})

await REDACTED(mediaId, REDACTED, REDACTED)
})
)
}
However, the following will not work as column.name returns name of a column as it is in database itself (column_name). However, for the purpose above I need to get the column name in the schema format columnName. How can I achieve this?
1 replies
DTDrizzle Team
Created by Marťafiixek on 2/2/2024 in #help
When using Postgres and timestamp, what does the mode string or date actually do?
Basically the title Advantages / disadvantages? I did not find any useful information in the docs Thanks
3 replies
DTDrizzle Team
Created by Marťafiixek on 12/11/2023 in #help
How do you structure your schemas?
No description
18 replies