Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はMorphiaを使用してmongoDBにアクセスしています。内部配列の長さでオブジェクトのリストを取得する必要があります。すべてのコレクションをJavaに取得してそこでソートせずに、どのように実行できるかを知っている人はいますか?
ネストされた配列サイズで追加のフィールドを作成し、$incを使用してこのフィールドを更新する必要があります。
$whereを使用することもできますが、非常に遅いです。
次のように、ネストされた配列の長さで検索します。
db.coll.find({ $where: "this.nestedArray.length > 3" });
しかし、私が言ったように、追加のフィールドを作成する方が良いです。
わかりました、見つけました:-)
dataStore.find(MyClass.class).order("-inner_array.length").asList(); トリックを行います。
dataStore.find(MyClass.class).order("-inner_array.length").asList();