How to query mongodb with “like” using the java api?

前端 未结 7 1941
谎友^
谎友^ 2020-12-14 00:59

this question is very similar to another post

I basically want to use the mongodb version of the sql \"like\" \'%m%\' operator

but in my situation i\'m using

7条回答
  •  生来不讨喜
    2020-12-14 01:21

    Might not be the actual answer, ( Executing the terminal query directly )

    public void displayDetails() {
        try {
            // DB db = roleDao.returnDB();
            MongoClient mongoClient = new MongoClient("localhost", 5000);
            DB db = mongoClient.getDB("test");
            db.eval("db.test.update({'id':{'$not':{'$in':[/su/]}}},{$set:{'test':'test3'}},true,true)", new Object[] {});
            System.out.println("inserted  ");
    
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    

提交回复
热议问题