Search code examples
mongodbscalacasbah

findOneById is not a member of com.mongodb.casbah.MongoCollection


I'm using Casbah 2.6.2 for MongoDB driver on scala

"org.mongodb" %% "casbah" % "2.6.2",

I'm having trouble accessing MongoCollection#findOneById (http://mongodb.github.io/casbah/api/#com.mongodb.casbah.MongoCollection). I'm getting the following error from console:

scala> db("test").findOneById(ObjectId("51d535b130047992f08cb043"))
<console>:10: error: value findOneById is not a member of com.mongodb.casbah.MongoCollection
          db("test").findOneById(ObjectId("51d535b130047992f08cb043"))

This is puzzling because #findOne and #find both work. Anyone have any idea why this is?


Solution

  • Notice the capital D in findOneByID

    db("test").findOneByID(ObjectId("51d535b130047992f08cb043"))