.Update[T](table, data)
Updates all records in a table, or a specific record, in the database.
Method Syntaxdb.Update[T](table, data)
NoteThis function replaces the current document / record data with the specified data.
Arguments | Description | ||
---|---|---|---|
thing required | The table name or the specific | ||
data optional | The document / record data to update. |
// Update a single record in the "persons" table updatedPerson, err := surrealdb.Update[Person](db, models.RecordID("persons", "person123"), Person{ Name: "John", Surname: "Smith", // Updated surname Location: models.NewGeometryPoint(-0.12, 23.00), // Updated location }) if err != nil { panic(err) } fmt.Printf("Updated person with a struct: %+v\n", updatedPerson)