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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -