mongo find()後加一個first()是什麼意思?

mongo2中只有find,findOne是mongo3中才有的,所以舊的寫法想達到和findOne一樣的效果,就需要在find後在加first()

 

In MongoDB 2 Java driver there was a method on the DBCollection class named findOne().

In the MongoDB 3 Java driver API, the findOne() method isn't there. So your new code for finding exactly one document becomes similar too this one:

collection.find(eq("_id", 3)).first()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章