Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
jio
Commits
3f2ea56f
Commit
3f2ea56f
authored
Oct 19, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mappingstorage: add bulk, repair and tests
parent
52773b10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
10 deletions
+60
-10
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+28
-4
test/jio.storage/mappingstorage.tests.js
test/jio.storage/mappingstorage.tests.js
+32
-6
No files found.
src/jio.storage/mappingstorage.js
View file @
3f2ea56f
...
...
@@ -273,12 +273,36 @@
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
};
MappingStorage
.
prototype
.
bulk
=
function
()
{
var
i
,
that
=
this
,
mapped_result
=
[];
return
this
.
_sub_storage
.
bulk
.
apply
(
arguments
)
MappingStorage
.
prototype
.
bulk
=
function
(
id_list
)
{
var
i
,
that
=
this
,
mapped_result
=
[],
promise_list
=
id_list
.
map
(
function
(
parameter
)
{
return
getSubStorageId
(
that
,
parameter
.
parameter_list
[
0
])
.
push
(
function
(
id
)
{
if
(
parameter
.
method
===
"
put
"
)
{
return
{
"
method
"
:
parameter
.
method
,
"
parameter_list
"
:
[
id
,
unmapDocument
(
parameter
.
parameter_list
[
1
])
]
};
}
return
{
"
method
"
:
parameter
.
method
,
"
parameter_list
"
:
[
id
]};
});
});
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
id_list_mapped
)
{
return
that
.
_sub_storage
.
bulk
(
id_list_mapped
);
})
.
push
(
function
(
result
)
{
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
)
{
mapped_result
.
push
(
mapDocument
(
that
,
result
[
i
]
),
false
);
mapped_result
.
push
(
mapDocument
(
that
,
result
[
i
]
,
false
)
);
}
return
mapped_result
;
});
...
...
test/jio.storage/mappingstorage.tests.js
View file @
3f2ea56f
...
...
@@ -827,7 +827,7 @@
/////////////////////////////////////////////////////////////////
// mappingStorage.bulk
/////////////////////////////////////////////////////////////////
/*
module("mappingstorage.bulk");
module
(
"
mappingstorage.bulk
"
);
test
(
"
bulk with map_all_property
"
,
function
()
{
stop
();
expect
(
2
);
...
...
@@ -837,7 +837,7 @@
sub_storage
:
{
type
:
"
mappingstorage2713
"
},
map_all_
doc
: true,
map_all_
property
:
true
,
mapping_dict
:
{
"
title
"
:
{
"
equal
"
:
"
otherTitle
"
},
"
id
"
:
{
"
equal
"
:
"
otherId
"
}
...
...
@@ -848,8 +848,28 @@
return
true
;
};
Storage2713.prototype.bulk = function () {
deepEqual(arguments, ["some", "arguments"], "bulk 2713 called");
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
if
(
option
.
query
===
'
otherId: "id1"
'
)
{
return
[{
id
:
"
foo
"
}];
}
if
(
option
.
query
===
'
otherId: "id2"
'
)
{
return
[{
id
:
"
bar
"
}];
}
throw
new
Error
(
"
invalid option:
"
+
option
.
toString
());
};
Storage2713
.
prototype
.
bulk
=
function
(
args
)
{
deepEqual
(
args
,
[{
method
:
"
get
"
,
parameter_list
:
[
"
foo
"
]
},
{
method
:
"
get
"
,
parameter_list
:
[
"
bar
"
]
}],
"
bulk 2713 called
"
);
return
[
{
"
otherId
"
:
"
foo
"
,
...
...
@@ -863,7 +883,13 @@
];
};
jio.bulk("some", "arguments")
jio
.
bulk
([{
method
:
"
get
"
,
parameter_list
:
[
"
id1
"
]
},
{
method
:
"
get
"
,
parameter_list
:
[
"
id2
"
]
}])
.
push
(
function
(
result
)
{
deepEqual
(
result
,
...
...
@@ -882,7 +908,7 @@
.
always
(
function
()
{
start
();
});
});
*/
});
/////////////////////////////////////////////////////////////////
// mappingStorage.repair
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment