golistic / pxmysql

Go MySQL driver using X Protocol
MIT License
14 stars 0 forks source link

feat(xmysql): insert documents into a collection #69

Closed geertjanvdk closed 1 year ago

geertjanvdk commented 1 year ago

We add the features to insert documents into a collection using the Collection.Add-method. The implementation follows the MySQL X DevAPI used by other MySQL connectors.

Example:

type Person struct {
  Name string `json:"name"`
  Age  int `json:"age"`
}

myColl, _ := db.CreateCollection("my_collection");

err := myColl.Add(&Person{Name: "Laurie", Age: 19 }).
  Add(&Person{Name: "Nadya", Age: 54 }, &Person{Name: "Lucas", Age: 32 }).
  Execute(context.Background())

Currently only struct type object can be added.

Resolves #66