spring-guides / gs-accessing-data-mongodb

Accessing Data with MongoDB :: Learn how to persist data in MongoDB.
http://spring.io/guides/gs/accessing-data-mongodb/
Apache License 2.0
139 stars 161 forks source link

How can I return fields like this find({},{"field1.field2":1}) #24

Closed charlee2025 closed 1 year ago

charlee2025 commented 5 years ago

The query : db.getCollection('homework').find({},{"field1.field2":1}) work well in robomongo. When I use spring @query like this: @Query(value = "{}", fields="{ ?0 : 1}") public List findByDoRecordKey(String key); // key is "field1.field2"

It is not work well. And it works like: db.getCollection('homework').find({},{"field1":1}) removed the field2.

Buzzardo commented 1 year ago

I suggest asking that question on Stack Overflow.