Commit 3d191693 authored by Aurel's avatar Aurel

Merge remote-tracking branch 'vincentB/mappingstorage' into nodejs-romain

parents 4590a3a1 c0733eb3
...@@ -167,6 +167,9 @@ ...@@ -167,6 +167,9 @@
} }
} }
} }
if (storage._map_id[0] === "equalSubProperty") {
storage._mapping_dict[storage._map_id[1]] = ["keep"];
}
if (storage._query.query !== undefined) { if (storage._query.query !== undefined) {
query_list.push(QueryFactory.create(storage._query.query)); query_list.push(QueryFactory.create(storage._query.query));
} }
...@@ -344,6 +347,9 @@ ...@@ -344,6 +347,9 @@
.push(function (sub_id) { .push(function (sub_id) {
return storage._sub_storage.put(sub_id, sub_doc); return storage._sub_storage.put(sub_id, sub_doc);
}) })
.push(function () {
return doc[storage._id_mapped];
})
.push(undefined, function (error) { .push(undefined, function (error) {
if (error instanceof jIO.util.jIOError) { if (error instanceof jIO.util.jIOError) {
return storage._sub_storage.post(sub_doc); return storage._sub_storage.post(sub_doc);
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
deepEqual( deepEqual(
jio.__storage._mapping_dict, jio.__storage._mapping_dict,
{"bar": ["equalSubProperty", "foo"]} {"bar": ["equalSubProperty", "foo"], "otherId": ["keep"]}
); );
deepEqual(jio.__storage._map_id, ["equalSubProperty", "otherId"]); deepEqual(jio.__storage._map_id, ["equalSubProperty", "otherId"]);
equal(jio.__storage._query.query.key, "foo"); equal(jio.__storage._query.query.key, "foo");
...@@ -130,13 +130,14 @@ ...@@ -130,13 +130,14 @@
Storage2713.prototype.get = function (id) { Storage2713.prototype.get = function (id) {
equal(id, "2713", "get 2713 called"); equal(id, "2713", "get 2713 called");
return {"title": "foo"}; return {"title": "foo", "otherId": "42"};
}; };
jio.get("42") jio.get("42")
.push(function (result) { .push(function (result) {
deepEqual(result, { deepEqual(result, {
"title": "foo" "title": "foo",
"otherId": "42"
}); });
}).push(undefined, function (error) { }).push(undefined, function (error) {
ok(false, error); ok(false, error);
...@@ -169,13 +170,14 @@ ...@@ -169,13 +170,14 @@
Storage2713.prototype.get = function (id) { Storage2713.prototype.get = function (id) {
equal(id, "2713", "get 2713 called"); equal(id, "2713", "get 2713 called");
return {"title": "foo"}; return {"title": "foo", "otherId": "42"};
}; };
jio.get("42") jio.get("42")
.push(function (result) { .push(function (result) {
deepEqual(result, { deepEqual(result, {
"title": "foo" "title": "foo",
"otherId": "42"
}); });
}).push(undefined, function (error) { }).push(undefined, function (error) {
ok(false, error); ok(false, error);
...@@ -652,7 +654,7 @@ ...@@ -652,7 +654,7 @@
test("with id equalSubProperty and id in doc", function () { test("with id equalSubProperty and id in doc", function () {
stop(); stop();
expect(2); expect(3);
var jio = jIO.createJIO({ var jio = jIO.createJIO({
type: "mapping", type: "mapping",
...@@ -667,9 +669,18 @@ ...@@ -667,9 +669,18 @@
return "42"; return "42";
}; };
Storage2713.prototype.put = function (id, doc) {
equal(id, "bar", "put 2713 called");
deepEqual(doc, {
"title": "foo",
"otherId": "bar"
}, "put 2713 called");
return "42";
};
jio.post({"title": "foo", "otherId": "bar"}) jio.post({"title": "foo", "otherId": "bar"})
.push(function (result) { .push(function (result) {
equal(result, "42"); equal(result, "bar");
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
ok(false, error); ok(false, error);
...@@ -1205,7 +1216,8 @@ ...@@ -1205,7 +1216,8 @@
"id": "42", "id": "42",
"value": { "value": {
"title": "foo", "title": "foo",
"smth": "bar" "smth": "bar",
"otherId": "42"
}, },
"doc": {} "doc": {}
}, },
...@@ -1213,7 +1225,8 @@ ...@@ -1213,7 +1225,8 @@
"id": "2713", "id": "2713",
"value": { "value": {
"title": "bar", "title": "bar",
"smth": "foo" "smth": "foo",
"otherId": "2713"
}, },
"doc": {} "doc": {}
} }
...@@ -1266,7 +1279,9 @@ ...@@ -1266,7 +1279,9 @@
"rows": [ "rows": [
{ {
"id": "42", "id": "42",
"value": {}, "value": {
"otherId": "42"
},
"doc": {} "doc": {}
} }
], ],
...@@ -1321,7 +1336,7 @@ ...@@ -1321,7 +1336,7 @@
"rows": [ "rows": [
{ {
"id": "42", "id": "42",
"value": {"title": "foo", "smth": "bar"}, "value": {"title": "foo", "smth": "bar", "otherId": "42"},
"doc": {} "doc": {}
} }
], ],
...@@ -1377,7 +1392,10 @@ ...@@ -1377,7 +1392,10 @@
"rows": [ "rows": [
{ {
"id": "42", "id": "42",
"value": {"title": "foo"}, "value": {
"otherId": "42",
"title": "foo"
},
"doc": {} "doc": {}
} }
], ],
...@@ -1463,9 +1481,11 @@ ...@@ -1463,9 +1481,11 @@
result, result,
[{ [{
"title": "bar", "title": "bar",
"otherId": "foo",
"bar": "foo" "bar": "foo"
}, { }, {
"title": "foo", "title": "foo",
"otherId": "bar",
"foo": "bar" "foo": "bar"
}], }],
"bulk test" "bulk test"
......
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