diff --git a/pkg/apiserver/infrastructure/datastore/mongodb/mongodb.go b/pkg/apiserver/infrastructure/datastore/mongodb/mongodb.go index 705e1dedd..30482afbd 100644 --- a/pkg/apiserver/infrastructure/datastore/mongodb/mongodb.go +++ b/pkg/apiserver/infrastructure/datastore/mongodb/mongodb.go @@ -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, }) } diff --git a/pkg/apiserver/infrastructure/datastore/mongodb/mongodb_test.go b/pkg/apiserver/infrastructure/datastore/mongodb/mongodb_test.go index 93b97933d..a108f88ab 100644 --- a/pkg/apiserver/infrastructure/datastore/mongodb/mongodb_test.go +++ b/pkg/apiserver/infrastructure/datastore/mongodb/mongodb_test.go @@ -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() {