.Merge[T](what, data)
Modifies all records in a table, or a specific record.
Method Syntaxdb.Merge[T](what, data)
NoteThis function merges the current document / record data with the specified data.
Arguments | Description | ||
---|---|---|---|
thing required | The table name or the specific | ||
data optional | The data with which to modify the records. |
Merging data within a single recordtype PersonMerge struct { ID models.RecordID `json:"id"` Settings struct { Active bool `json:"active"` Marketing bool `json:"marketing"` } `json:"settings"` } // Define the partial update data using a struct mergeData := PersonMerge{ ID: models.NewRecordID("person", "tobie"), Settings: struct { Active bool `json:"active"` Marketing bool `json:"marketing"` }{ Active: true, Marketing: false, }, } // Perform the merge operation 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)