Commit eec60f02 authored by Tristan Cavelier's avatar Tristan Cavelier

jio.js updated

parent 60eac4f9
...@@ -284,16 +284,10 @@ var storage = function (spec, my) { ...@@ -284,16 +284,10 @@ var storage = function (spec, my) {
that.addJob = function (method, storage_spec, doc, option, success, error) { that.addJob = function (method, storage_spec, doc, option, success, error) {
var command_opt = { var command_opt = {
doc: doc,
options: option, options: option,
callbacks: {success: success, error: error} callbacks: {success: success, error: error}
}; };
if (doc) {
if (method === 'get') {
command_opt.docid = doc;
} else {
command_opt.doc = doc;
}
}
jobManager.addJob(job({ jobManager.addJob(job({
storage: priv.storage(storage_spec || {}), storage: priv.storage(storage_spec || {}),
command: priv.newCommand(method, command_opt) command: priv.newCommand(method, command_opt)
...@@ -2302,7 +2296,8 @@ Object.defineProperty(that, "put", { ...@@ -2302,7 +2296,8 @@ Object.defineProperty(that, "put", {
/** /**
* Get a document. * Get a document.
* @method get * @method get
* @param {string} docid The document id: "doc_id" or "doc_id/attachmt_id". * @param {string} doc The document object. Contains at least:
* - {string} _id The document id: "doc_id" or "doc_id/attachment_id"
* @param {object} options (optional) Contains some options: * @param {object} options (optional) Contains some options:
* - {number} max_retry The number max of retries, 0 = infinity. * - {number} max_retry The number max of retries, 0 = infinity.
* - {string} rev The revision we want to get. * - {string} rev The revision we want to get.
...@@ -2318,14 +2313,14 @@ Object.defineProperty(that, "get", { ...@@ -2318,14 +2313,14 @@ Object.defineProperty(that, "get", {
configurable: false, configurable: false,
enumerable: false, enumerable: false,
writable: false, writable: false,
value: function (id, options, success, error) { value: function (doc, options, success, error) {
var param = priv.parametersToObject( var param = priv.parametersToObject(
[options, success, error], [options, success, error],
{max_retry: 3} {max_retry: 3}
); );
priv.addJob(getCommand, { priv.addJob(getCommand, {
docid: id, doc: doc,
options: param.options, options: param.options,
callbacks: {success: param.success, error: param.error} callbacks: {success: param.success, error: param.error}
}); });
...@@ -2419,19 +2414,13 @@ Object.defineProperty(that, "putAttachment", { ...@@ -2419,19 +2414,13 @@ Object.defineProperty(that, "putAttachment", {
enumerable: false, enumerable: false,
writable: false, writable: false,
value: function (doc, options, success, error) { value: function (doc, options, success, error) {
var param, k, doc_with_underscores = {}; var param = priv.parametersToObject(
param = priv.parametersToObject(
[options, success, error], [options, success, error],
{max_retry: 0} {max_retry: 0}
); );
for (k in doc) {
if (doc.hasOwnProperty(k) && k.match('[^_].*')) {
doc_with_underscores["_" + k] = doc[k];
}
}
priv.addJob(putAttachmentCommand, { priv.addJob(putAttachmentCommand, {
doc: doc_with_underscores, doc: doc,
options: param.options, options: param.options,
callbacks: {success: param.success, error: param.error} callbacks: {success: param.success, error: param.error}
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment