I’m using casbah in Scala to do inserts into MongoDB and not understanding some behavior I’m seeing.
val wr = dao.collection.insert(myRecord, dao.defaultWriteConcern)
val error = wr.getCachedLastError
Ok, nothing fancy here. In fact if I insert a document it works great. My problem is if I go and insert the same document again then my error == null, where I would expect some kind of indication I’m trying to insert a record that already exists.
Is this because my defaultWriteConcern is too “loose”, or am I just not understanding the correct behavior? I’m using casbah 2.5.0.SNAPSHOT. I was using an older version and I seem to remember it gave me some kind of an error, which is what I would expect.
You won’t receive an error creating a record with duplicate content unless you’re violating a unique index with a field that is duplicated.