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
Sillvva7mo ago
Drizzle ORM - PostgreSQL column types
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Einzi
EinziOP7mo 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
Sillvva7mo ago
It should
Einzi
EinziOP7mo ago
OK thanks
Sillvva
Sillvva7mo 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