.Upsert[T](table, data)
Creates or updates a specific record.
Method Syntaxdb.Upsert[T](table, data)
NoteThis function creates a new document / record or replaces the current one with the specified data.
Arguments | Description | ||
---|---|---|---|
table required | The table to upsert the record to. | ||
data required | The document / record data to upsert. |
// Upsert a record in the "persons" table person, err := surrealdb.Upsert[Person](db, models.Table("persons"), Person{ Name: "John", Surname: "Doe", Location: models.NewGeometryPoint(-0.11, 22.00), }) if err != nil { panic(err) } fmt.Printf("Upserted person with a struct: %+v\n", person)