db.save({from: "test", to: "all", body: "wibble"}, null, {collection: "messages",contentType: "application/json"},function(result) { var uri = result.docuri; logger.debug("TEST: Generated docuri: " + uri); // now fetch it logger.debug("****** Doc created. Fetching doc."); var doc = db.get(uri, function(result) { // now print it //logger.debug("****** Doc content: " + JSON.stringify(result.doc)); // now delete it logger.debug("****** deleting doc"); db.delete(uri, function(result) { logger.debug("****** Doc deleted"); //assert.isNull(result.doc); assert(undefined == result.doc,"result doc should not be undefined"); done(); }); }); });
db.rollbackTransaction(function(result) { if (result.inError) { logger.debug("TEST: ROLLBACK: ERROR IN COMMIT: " + JSON.stringify(result)); callback(false); } else { logger.debug("TEST: ROLLBACK: Fetching abandoned Doc."); db.get(uri, function(result) { if (result.inError) { // this is a good thing here logger.debug("TEST: ROLLBACK: get in error: " + JSON.stringify(result.error)); done(); } else { // now print it logger.debug("TEST: ROLLBACK: Doc content: " + JSON.stringify(result.doc)); assert(false,"Document should not exist after rollback"); done(); } // end else inError }); } });