struct Instrument: Encodable \{
let id: Int
let name: String
\}
let instrument = Instrument(id: 1, name: "piano")
try await supabase.database
.from("instruments")
.insert(instrument)
.execute()
Create a record and return it
struct Instrument: Codable \{
let id: Int
let name: String
\}
let country: Country = try await supabase.database
.from("instruments")
// use `returning: .representation` to return the created object.
.insert(Instrument(id: 1, name: "piano"), returning: .representation)
// specify you want a single value returned, otherwise it returns a list.
.single()
.execute()
.value
Bulk create
struct Instrument: Encodable \{
let id: Int
let name: String
\}
let instruments = [
Instrument(id: 1, name: "piano"),
Instrument(id: 1, name: "guitar"),
]
try await supabase.database
.from("instruments")
.insert(instruments)
.execute()