user1113883
user1113883

Reputation:

jQuery CouchDB request returns "created" but document not added to database

I'm using jquery.couch.js to write a document to my CouchDB. I've taken care of parsing the JSON data and getting the request ready. When my script actually sends the $.couch.db.saveDoc() command, I get a 201 Created response code for my post request, which also includes the following:

{"ok":true,"id":"...","rev":"..."}

(where "..." is an actual UUID)

But when I check my CouchDB afterwards, no document has been created.

I've encountered this before, but it always ends up getting resolved by some other method. Basically it seems like the couch returns "ok":true regardless of whether the document is created. The part that really gets me though is that it actually returns a generated UUID (which means that the request actually reached my CouchDB, if I'm not mistaken). So I can't figure out why the document isn't written.

Has anyone encountered this issue before?

Upvotes: 0

Views: 257

Answers (1)

Sam Bisbee
Sam Bisbee

Reputation: 4441

A few things to note here...

  • CouchDB will only return a 201 Created when the document has been successfully fsync'd. This is why CouchDB is more durable than other databases, such as MongoDB. So your data is absolutely on disk.
  • And when I say "absolutely on disk" I mean "only if you have delayed_commits set to false in your configuration".
  • How are you confirming that the document has been created? Are you trying to retrieve the document at its URL (/database/docID) or from a view? If it's from a view then your index might not be updated yet.

Upvotes: 1

Related Questions