1

初始条件:

  • 拥有一系列城市的旅行者的集合
  • 目的地(城市)列表。

如何检索在目的地列表中包含三个城市的所有旅行者?目前我只能计算一个旅行者的目的地总数......

    BasicDBObject query = new BasicDBObject("destinations", new BasicDBObject("$exists", true));

    query.put("country.$id", countryId);
    query.put("$where","this.destinations.length <= " + maxNumDestinations);

    DB db = getMongoDbFactory().getDb();
    DBCollection travellerCollection = db.getCollection("traveller");
    DBCursor cursor = travellerCollection.find(query);
    return cursor;
4

0 回答 0