Spring mongo repository slice

前端 未结 3 722
无人共我
无人共我 2021-01-16 19:56

I am using spring-sata-mongodb 1.8.2 with MongoRepository and I am trying to use the mongo $slice option to limit a list size when query, but I can\'t find this option in th

3条回答
  •  孤街浪徒
    2021-01-16 20:55

    Providing an abstraction for the $slice operator in Query is still an open issue. Please vote for DATAMONGO-1230 and help us prioritize.

    For now you still can fall back to using BasicQuery.

    String qry = "{ \"_id\" : \"record-id\"}";
    String fields = "{\"fields\": { \"$slice\": 2} }";
    
    BasicQuery query = new BasicQuery(qry, fields);
    

提交回复
热议问题