.Insert[T](table, data)
Inserts one or multiple records in the database.
Method Syntaxdb.Insert[T](table, data)
Arguments | Description | ||
---|---|---|---|
table optional | Optionally pass along a table to insert into. | ||
data optional | Either a single document/record or an array of documents/records to insert | ||
cancellationToken optional | The cancellationToken enables graceful cancellation of asynchronous operations. |
// Insert an entry person2, err := surrealdb.Insert[Person](db, models.Table("persons"), map[interface{}]interface{}{ "Name": "Jane", "Surname": "Smith", "Location": models.NewGeometryPoint(-0.12, 22.01), }) if err != nil { panic(err) } fmt.Printf("Inserted person with a map: %+v\n", person2)