Java&Mongo: get object where field exist

后端 未结 2 1859
一生所求
一生所求 2021-01-26 03:56

Situation: I have collection with documents, each document contains such fields: \"_id\"(ObjectId), \"userId\"(String), but it also can be field \"files\"(Object).

When

2条回答
  •  感动是毒
    2021-01-26 04:42

    Another possibility is to use org.springframework.data.mongodb.repository.Query annotation on your method (useful when using MongoRepository):

    @Query(value="{ files : { $exists : true } }")
    

提交回复
热议问题