-
Notifications
You must be signed in to change notification settings - Fork 0
Description
User Story
As a developer working with a collection,
I want to have a Remove method available in the collection,
So that I can easily delete documents from the collection when necessary.
Acceptance Criteria
-
Given that I have a collection instance, when I call the
Remove()method with a valid search condition, it should delete the matching document(s) from the collection. -
Given that I have a collection instance, when I call the
Remove()method with an invalid search condition, it should return an appropriate error and not delete any documents whenExecute()is called. -
Given that I have a collection instance, when I call the
Remove()method with a valid search condition that matches multiple documents, it should delete all matching documents from the collection. -
Given that I have a collection instance, when I call the
Removemethod with a valid search condition, it should return a result which includesRowsAffected. -
Given that I have a collection instance, when I call the
Removemethod, it should not modify or alter the state of the collection instance other than deleting the specified document(s). -
Given that I have a collection instance, when I call the
Removemethod with a document search condition, it should not delete documents that do not match the provided search condition.
Technical notes
- Follow the EBNF found at https://dev.mysql.com/doc/x-devapi-userguide/en/crud-ebnf-collection-crud-functions.html
Example
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
myColl, _ := db.GetCollection("my_collection")
myColl.Remove("name like :name AND age < :age").
Limit(1).Bind("name","N%").
Bind("age", 60).
Execute(context.Background());Value
By adding the Remove method to the collection, we provide developers with a convenient and efficient way to delete documents from the collection.