.Merge[T](what, data)
Modifies all records in a table, or a specific record.
Method Syntax
db.Merge[T](what, data)
This function merges the current document / record data with the specified data.
Arguments
| Arguments | Description |
|---|
thing required | The table name or the specific RecordId to merge. |
data optional | The data with which to modify the records. |
Example usage
Merging data within a single record
type PersonMerge struct {
ID models.RecordID `json:"id"`
Settings struct {
Active bool `json:"active"`
Marketing bool `json:"marketing"`
} `json:"settings"`
}
mergeData := PersonMerge{
ID: models.NewRecordID("person", "tobie"),
Settings: struct {
Active bool `json:"active"`
Marketing bool `json:"marketing"`
}{
Active: true,
Marketing: false,
},
}
updatedPerson, err := surrealdb.Merge[Person, models.RecordID](db, mergeData.ID, mergeData)
if err != nil {
panic(err)
}
fmt.Printf("Merged person record with struct: %+v\n", updatedPerson)