Commit d7ecff55 authored by Bryan Kaperick's avatar Bryan Kaperick

Still debugging query issue.

parent 44628a99
...@@ -48,7 +48,9 @@ ...@@ -48,7 +48,9 @@
sort_on: [['_revision', 'descending']], sort_on: [['_revision', 'descending']],
limit: [0, 1] limit: [0, 1]
}; };
return substorage.buildQuery(options); //return substorage.buildQuery(options);
return substorage.allDocs(options);
}) })
.push(function (query_results) { .push(function (query_results) {
if (query_results.length > 0) { if (query_results.length > 0) {
...@@ -141,21 +143,21 @@ ...@@ -141,21 +143,21 @@
BryanStorage.prototype.hasCapacity = function () { BryanStorage.prototype.hasCapacity = function () {
return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments); return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments);
}; };
/**
BryanStorage.prototype.allDocs = function (options) { BryanStorage.prototype.allDocs = function (options) {
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
} }
console.log("options", options); console.log("options", options);
/**
if (options === undefined) { if (options === undefined) {
options = {query: ""}; options = {query: ""};
} }
options.query = '(' + options.query + ') AND NOT (_deprecated = true)'; options.query = '(' + options.query + ') AND NOT (_deprecated = true)';
console.log("query string: ", options.query); console.log("query string: ", options.query);
**/
return this._sub_storage.allDocs.apply(this._sub_storage, options); return this._sub_storage.allDocs.apply(this._sub_storage, options);
//return this._sub_storage.buildQuery.apply(this._sub_storage, options); //return this._sub_storage.buildQuery.apply(this._sub_storage, options);
}; };
**/
BryanStorage.prototype.buildQuery = function (options) { BryanStorage.prototype.buildQuery = function (options) {
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
......
...@@ -25,7 +25,12 @@ ...@@ -25,7 +25,12 @@
// create storage of type "bryan" with memory as substorage // create storage of type "bryan" with memory as substorage
var jio = jIO.createJIO({ var jio = jIO.createJIO({
type: "bryan", type: "bryan",
sub_storage: {type: "memory"} sub_storage: {
type: "uuid",
sub_storage: {
type: "memory"
}
}
}); });
jio.put("bar", {"title": "foo"}); jio.put("bar", {"title": "foo"});
...@@ -54,12 +59,12 @@ ...@@ -54,12 +59,12 @@
sub_storage: { sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
//type: "memory" type: "memory"
type: "indexeddb", //type: "indexeddb",
database: dbname //database: dbname
} }
} }
}), });/**,
not_bryan = jIO.createJIO({ not_bryan = jIO.createJIO({
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -71,10 +76,12 @@ ...@@ -71,10 +76,12 @@
} }
} }
}); });
**/
jio.put("doc1", { jio.put("doc1", {
"title": "rev0", "title": "rev0",
"subtitle": "subrev0" "subtitle": "subrev0"
}) })
/**
.push(function () {return jio.get("doc1"); }) .push(function () {return jio.get("doc1"); })
.push(function (result) { .push(function (result) {
deepEqual(result, { deepEqual(result, {
...@@ -103,14 +110,15 @@ ...@@ -103,14 +110,15 @@
"subtitle": "subrev2" "subtitle": "subrev2"
}, "Retrieve second edition of document correctly"); }, "Retrieve second edition of document correctly");
}) })
**/
.push(function () { .push(function () {
var options = { var options = {
//query: ""//title: rev2" query: "title: rev0"
}; };
// //
// //
return jio.buildQuery(options); //return jio.buildQuery(options);
//return jio.allDocs(options); return jio.allDocs(options);
// //
// //
}) })
...@@ -127,7 +135,7 @@ ...@@ -127,7 +135,7 @@
"subtitle": "subrev2" "subtitle": "subrev2"
}, "Retrieve queried document correctly"); }, "Retrieve queried document correctly");
}) })
/**
// When not_bryan queries the storage, all documents are returned. // When not_bryan queries the storage, all documents are returned.
.push(function () { .push(function () {
var options = { var options = {
...@@ -152,6 +160,7 @@ ...@@ -152,6 +160,7 @@
}, },
"Get the earliest copy of the doc with all metadata."); "Get the earliest copy of the doc with all metadata.");
}) })
**/
.fail(function (error) { .fail(function (error) {
console.log(error); console.log(error);
ok(false, error); ok(false, error);
...@@ -231,7 +240,7 @@ ...@@ -231,7 +240,7 @@
}, "Retrieve other document correctly"); }, "Retrieve other document correctly");
}) })
.push(function () { .push(function () {
return jio.buildQuery({ return jio.allDocs({
query: "" query: ""
}); });
}) })
...@@ -240,7 +249,7 @@ ...@@ -240,7 +249,7 @@
equal(result.length, 2, "Empty query returns only non-deprecated docs"); equal(result.length, 2, "Empty query returns only non-deprecated docs");
}) })
.push(function () { .push(function () {
return jio.buildQuery({ return jio.allDocs({
query: 'attr: "version1"' query: 'attr: "version1"'
}); });
}) })
...@@ -257,7 +266,7 @@ ...@@ -257,7 +266,7 @@
}, "Retrieve other document correctly"); }, "Retrieve other document correctly");
}) })
.push(function () { .push(function () {
return jio.buildQuery({ return jio.allDocs({
query: '(_doc_id: "other_doc")' query: '(_doc_id: "other_doc")'
}); });
}) })
...@@ -265,7 +274,7 @@ ...@@ -265,7 +274,7 @@
equal(result.length, 0, "Correct number of results returned"); equal(result.length, 0, "Correct number of results returned");
}) })
.push(function () { .push(function () {
return jio.buildQuery({ return jio.allDocs({
query: '(_revision: 0)' query: '(_revision: 0)'
}); });
}) })
...@@ -273,7 +282,7 @@ ...@@ -273,7 +282,7 @@
equal(result.length, 0, "Correct number of results returned"); equal(result.length, 0, "Correct number of results returned");
}) })
.push(function () { .push(function () {
return jio.buildQuery({ return jio.allDocs({
query: '' query: ''
}); });
}) })
...@@ -287,7 +296,7 @@ ...@@ -287,7 +296,7 @@
query: "_doc_id: main_doc", query: "_doc_id: main_doc",
sort_on: [["_revision", "ascending"]] sort_on: [["_revision", "ascending"]]
}; };
return not_bryan.buildQuery(options); return not_bryan.allDocs(options);
}) })
.push(function (results) { .push(function (results) {
equal(results.length, 3, "should get all 3 deprecated versions."); equal(results.length, 3, "should get all 3 deprecated versions.");
...@@ -310,7 +319,7 @@ ...@@ -310,7 +319,7 @@
query: "_doc_id: main_doc", query: "_doc_id: main_doc",
sort_on: [["_revision", "ascending"]] sort_on: [["_revision", "ascending"]]
}; };
return not_bryan.buildQuery(options); return not_bryan.allDocs(options);
}) })
.push(function (results) { .push(function (results) {
return not_bryan.get(results[1].id); return not_bryan.get(results[1].id);
......
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