Java&Mongo: get object where field exist

后端 未结 2 1852
一生所求
一生所求 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:36

    You can construct this Query to get all documents that contains files filed:

    Query.query(Criteria.where("files").exists(true))
    

提交回复
热议问题