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