初期状態:
- 都市の配列を持つ旅行者のコレクション
- 目的地 (都市) のリスト。
目的地リストに 3 つの都市があるすべての旅行者を取得するにはどうすればよいでしょうか? 現時点では、旅行者の目的地の総数しか数えることができません...
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;