SurrealDB Docs Logo

Enter a search query

.Update[T](table, data)

Updates all records in a table, or a specific record, in the database.

Method Syntax
db.Update[T](table, data)
Note

This function replaces the current document / record data with the specified data.

Arguments

ArgumentsDescription
thing required

The table name or the specific RecordId to update.

data optional

The document / record data to update.

Example usage

// 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)

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install