0

In my project, I'm using Casbah and I reffered http://mongodb.github.io/casbah/tutorial.html tutorial. According to that I've implemented

     val mongoClient = MongoClient
     val db = mongoClient("db_name")
     val coll = db("coll_name")
     val a = MongoDBObject("hello" -> "world")

Then next step is not going to work.

coll.insert(a)

I'm using, "org.mongodb"%% "casbah" % 2.7.0-RC0

what is this issue ?

Shashika
  • 1,606
  • 6
  • 28
  • 47

2 Answers2

0

If running mongodb on localhost and the default port try changing:

val mongoClient = MongoClient()

So you call the apply method and return an instance of MongoClient not the object..

Ross
  • 17,861
  • 2
  • 55
  • 73
0
MongoFactory.coll.save(a)

use save() to save MongoDBObject.

Nilesh
  • 2,054
  • 3
  • 23
  • 43