mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Function update one now considers the protection key using the update operator
This commit is contained in:
+4
-13
@@ -107,28 +107,19 @@ func applySkip(query *Query, filter interface{}) (ok bool) {
|
||||
|
||||
func applyProtection(query *Query, filter interface{}) (ok bool) {
|
||||
|
||||
var x *primitive.ObjectID
|
||||
var v *int64
|
||||
var keyDoc = primitive.M{}
|
||||
|
||||
switch filter := filter.(type) {
|
||||
case protection.Key:
|
||||
x = &filter.X
|
||||
v = &filter.V
|
||||
filter.PutToDocument(keyDoc)
|
||||
case *protection.Key:
|
||||
x = &filter.X
|
||||
v = &filter.V
|
||||
filter.PutToDocument(keyDoc)
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
if x.IsZero() {
|
||||
query.And(primitive.M{"_x": primitive.M{"$exists": false}})
|
||||
query.And(primitive.M{"_v": primitive.M{"$exists": false}})
|
||||
} else {
|
||||
query.And(primitive.M{"_x": *x})
|
||||
query.And(primitive.M{"_v": *v})
|
||||
}
|
||||
query.And(keyDoc)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user