Each document in a couchDB database instance needs an identification. It can be anything but must be unique in the database. Often GUIDs (or UUIDs) are used.
couchDB assigns a document revision number to each document. Old versions are kept. The attribute name used is _rev.
By using the Http PUT request with an identification a JSON object may be stored for the first time in a database. Here colorDictionary is used as identification.
// prepare request
var req = new XMLHttpRequest();
req.open("PUT", "../colorDictionary", false); // request type, URL, asynchronous = false
var mimeType="application/json";
req.setRequestHeader('Content-Type', mimeType);
console.log("Object to put in couchDB"); // print out the object on the console
console.log(JSON.stringify(myDict, undefined, 4)); // use pretty printing
req.send(JSON.stringify(myDict)); // send the JavaScript object as a string.

As the answer to the request couchDB gives buck a responseText. It contains the string version of a result JSON object. If the storing operation was successful that object has an attribute "ok" which is then true.
The same code as above without comments and relying on default values for the mime type. The identification used here is "colorDictionary2".
var req = new XMLHttpRequest();
req.open("PUT", "../colorDictionary2", false);
req.send(JSON.stringify(myDict));
When you do not want to provide an identification value for the JSON object to be stored you need to use the Http POST request. The couchDB instance will then automatically assign an identification key.
var req = new XMLHttpRequest();
req.open("POST", "../", false);
req.setRequestHeader('Content-Type', "application/json");
req.send(JSON.stringify(myObj));
Here it is compulsory to set the header information, otherwise there
req.responseText will contain an error message. The database system assigns an identification to the document stored. This identification is given back in
req.responseText.