php - Get only different entries in MongoDB -
i have got collection in mongodb different files. each file contains filename , version number. how can find latest of each files?
the documents this:
_id: objectid("51834f42ddf4010a00000000"), f: "test.php", v: 1, code: "pd8ncg0kzwnobyanr3v0zw4gvgfnisc7dqoncj8+"
f = filename, v = version number, (code = file content)
let's there 1 file name test.php
, 1 called second_test.php
. want select document highest versions number of each of these files.
any highly appreciated.
db.files.find("f" => "test.php").sort({"v" => -1}).limit(1).first() db.files.find("f" => "second_test.php").sort({"v" => -1}).limit(1).first()
Comments
Post a Comment