K
Kysely15mo ago
Nil

how to insert an array of strings

hey guys, I wanted to know how to store an array of strings with kysely, I created my table using migrations:
await db.schema
.withSchema("schemaName")
.createTable("tableName")
.addColumn("id", "bigserial", (col) => col.primaryKey())
.addColumn("columnName", sql`text[]`)
await db.schema
.withSchema("schemaName")
.createTable("tableName")
.addColumn("id", "bigserial", (col) => col.primaryKey())
.addColumn("columnName", sql`text[]`)
I ran it this way and it created the table, but the problem now is inserting the data:
const insertedProductId: any = await db
.insertInto("teleclinica.product")
.values({
columnName: ["data1", "data2"]
})
.returning(['id'])
.executeTakeFirstOrThrow()
const insertedProductId: any = await db
.insertInto("teleclinica.product")
.values({
columnName: ["data1", "data2"]
})
.returning(['id'])
.executeTakeFirstOrThrow()
I'm using postgresql, could you help me please
3 Replies
koskimas
koskimas15mo ago
What's the problem? What's the type of columnName in the table interface?
Nil
Nil15mo ago
@koskimas It is returning QueryCompilerError: Could not serialize value when I try to register
koskimas
koskimas15mo ago
Ok so you aren't using any of the built-in dialects. You need to open an issue in the 3rd party dislect's repo you're using. We have no control over those.
Want results from more Discord servers?
Add your server