Handle both bson.D and bson.M on Find results
This commit is contained in:
@@ -15,7 +15,9 @@ func TestFind_Default(t *testing.T) {
|
||||
client := GetMongoClient()
|
||||
|
||||
filter := bson.M{"name": bson.M{"$regex": "OSRAM"}}
|
||||
findResult, err := client.Find(context.Background(), "mydb", "mycollection", filter, 0)
|
||||
findResult, err := client.Find(context.Background(), "mydb", "mycollection", filter, &FindOptions{
|
||||
Offset: int64(0),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to insertOne %#v", err)
|
||||
}
|
||||
@@ -74,6 +76,7 @@ func TestFind_Discriminator(t *testing.T) {
|
||||
|
||||
client := GetMongoClient()
|
||||
client.AddDefinition(store)
|
||||
|
||||
client.AddDefinition(offer)
|
||||
|
||||
// Save two offers with the similar name in different stores each.
|
||||
@@ -97,7 +100,9 @@ func TestFind_Discriminator(t *testing.T) {
|
||||
// Now searching in store str_1234 for OSRAM should return only one
|
||||
|
||||
filter := bson.M{"name": bson.M{"$regex": "OSRAM*"}}
|
||||
findResult, err := client.Find(ctx1, "mydb", "offer", filter, 0)
|
||||
findResult, err := client.Find(ctx1, "mydb", "offer", filter, &FindOptions{
|
||||
Offset: int64(0),
|
||||
})
|
||||
if err != nil { t.Fatalf("Failed to find %#v", err) }
|
||||
|
||||
dataAny, hasData := findResult["data"]
|
||||
|
||||
Reference in New Issue
Block a user