update AssignOther
This commit is contained in:
parent
57ea2d882a
commit
81df358020
|
@ -3,6 +3,7 @@ package model
|
||||||
import (
|
import (
|
||||||
"github.com/Selly-Modules/mongodb"
|
"github.com/Selly-Modules/mongodb"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,7 +76,18 @@ func (q *CommonQuery) AssignOther(cond bson.M) {
|
||||||
// Query fields in other object
|
// Query fields in other object
|
||||||
if len(q.Other) > 0 {
|
if len(q.Other) > 0 {
|
||||||
for key, value := range q.Other {
|
for key, value := range q.Other {
|
||||||
|
switch v := value.(type) {
|
||||||
|
case []primitive.ObjectID:
|
||||||
|
cond["other."+key] = bson.M{
|
||||||
|
"$in": v,
|
||||||
|
}
|
||||||
|
case []string:
|
||||||
|
cond["other."+key] = bson.M{
|
||||||
|
"$in": v,
|
||||||
|
}
|
||||||
|
default:
|
||||||
cond["other."+key] = value
|
cond["other."+key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue