Array of Objects

Hello, I wanted to know how can I create an array of objects in a table. Like
fields: {
name: string,
value: string
}[]
fields: {
name: string,
value: string
}[]
5 Replies
Sillvva
Sillvva6mo ago
Drizzle ORM - PostgreSQL column types
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Einzi
EinziOP6mo ago
Will something like this work
//in the table
jsonb2: jsonb('jsonb2').default([{ foo: "bar" }, { bar: "foo" }])

// to insert
db.insert(table).values([{ jsonb2: [{ first: "first" }, { second: "second" }] }])
//in the table
jsonb2: jsonb('jsonb2').default([{ foo: "bar" }, { bar: "foo" }])

// to insert
db.insert(table).values([{ jsonb2: [{ first: "first" }, { second: "second" }] }])
Sillvva
Sillvva6mo ago
It should
Einzi
EinziOP6mo ago
OK thanks
Sillvva
Sillvva6mo ago
Also might be worth adding something like this on the schema definition for type inference .$type<{ foo: string }>()
Want results from more Discord servers?
Add your server