Fix: fail to query the count with mongodb

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
barnettZQG
2022-05-27 09:36:53 +08:00
parent adc99bf390
commit ee2b446b5c
2 changed files with 6 additions and 1 deletions
@@ -275,7 +275,7 @@ func (m *mongodb) Count(ctx context.Context, entity datastore.Entity, filterOpti
if entity.Index() != nil {
for k, v := range entity.Index() {
filter = append(filter, bson.E{
Key: k,
Key: strings.ToLower(k),
Value: v,
})
}
@@ -232,6 +232,11 @@ var _ = Describe("Test mongodb datastore driver", func() {
}})
Expect(err).ShouldNot(HaveOccurred())
Expect(count).Should(Equal(int64(3)))
app.Name = "kubevela-app-3"
count, err = mongodbDriver.Count(context.TODO(), &app, &datastore.FilterOptions{})
Expect(err).ShouldNot(HaveOccurred())
Expect(count).Should(Equal(int64(1)))
})
It("Test isExist function", func() {