Shashika
Shashika

Reputation: 1636

Some Casbah functions not working

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 ?

Upvotes: 0

Views: 45

Answers (2)

Nilesh
Nilesh

Reputation: 2180

MongoFactory.coll.save(a)

use save() to save MongoDBObject.

Upvotes: 0

Ross
Ross

Reputation: 18111

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..

Upvotes: 0

Related Questions