mongodb数组多值查询(条件:数据库中必须包含条件信息)

  项目开发中遇到一种情况:

    1、字段属性为数组string[]可传多值

       2、mongodb中字段类型为数组

              3、查询数据:传入值必须同时在数据库中存在  ,其中key是字段名

db.getCollection('demo').find({"key": {$all:['30854','12345']}})

    代码:查询单值 all或is均可

criteriaPlatformId.andOperator(new Criteria("platform_id_list").is("['ALL']"));

    代码:查询多值 all

criteriaPlatformId.andOperator(new Criteria("platform_id_list").all("['30854','12345']"));
posted @ 2019-12-25 17:29  紫色水杯  阅读(3034)  评论(0编辑  收藏  举报