golistic / pxmysql

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

Insert documents into a collection #66

Closed geertjanvdk closed 1 year ago

geertjanvdk commented 1 year ago

User Story

As a Go developer working with the MySQL X DevAPI, I want to have a chained "Add" CRUD method available in the Collection object, So that I can efficiently add multiple data records and execute them in a single operation.

Acceptance Criteria

Example

Based on https://dev.mysql.com/doc/x-devapi-userguide/en/collection-add.html.


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

Value

By adding a chained `Add() method to the MySQL X DevAPI Collection-type in Go, we enable developers to efficiently add multiple data records and execute them in a single operation.