incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whims...@aol.com
Subject creating a session then trying to save a doc fails due to authorization problems
Date Tue, 24 Aug 2010 19:14:43 GMT

 I am using couch.js to get a session. The session is created successfully according to firebug.
Next I want to add a new document to a database I've created

The database is called joe at localhost:5984/joe
joe's login pass is joe:cool
The session command goes through correctly in firebug but just returns json of

{"ok":true,"name":"joe","roles":["user"]}

Next I want to use the following in javascript

mydb = new CouchDB("joe");
mydb.createDb();
doc={"username":"joe","filename":"joesfile","data":"here is joe's data"};
mydb.save(doc);

But this fails due to authorization problems.
Is there something I'm going to need to include in the options in the mydb.save(doc,options)?

The couch.js function is
 // Save a document to the database
  this.save = function(doc, options) {
    if (doc._id == undefined) {
      doc._id = CouchDB.newUuids(1)[0];
    }

    this.last_req = this.request("PUT", this.uri  +
        encodeURIComponent(doc._id) + encodeOptions(options),
        {body: JSON.stringify(doc)});
    CouchDB.maybeThrowError(this.last_req);
    var result = JSON.parse(this.last_req.responseText);
    doc._rev = result.rev;
    return result;
  }






Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message