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
b076d049
Commit
b076d049
authored
Oct 19, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mappingstorage: add bulk, repair and tests
parent
89139428
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 @
b076d049
...
@@ -273,12 +273,36 @@
...
@@ -273,12 +273,36 @@
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
);
};
};
MappingStorage
.
prototype
.
bulk
=
function
()
{
MappingStorage
.
prototype
.
bulk
=
function
(
id_list
)
{
var
i
,
that
=
this
,
mapped_result
=
[];
var
i
,
return
this
.
_sub_storage
.
bulk
.
apply
(
arguments
)
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
)
{
.
push
(
function
(
result
)
{
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
)
{
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
;
return
mapped_result
;
});
});
...
...
test/jio.storage/mappingstorage.tests.js
View file @
b076d049
...
@@ -827,7 +827,7 @@
...
@@ -827,7 +827,7 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// mappingStorage.bulk
// mappingStorage.bulk
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/*
module("mappingstorage.bulk");
module
(
"
mappingstorage.bulk
"
);
test
(
"
bulk with map_all_property
"
,
function
()
{
test
(
"
bulk with map_all_property
"
,
function
()
{
stop
();
stop
();
expect
(
2
);
expect
(
2
);
...
@@ -837,7 +837,7 @@
...
@@ -837,7 +837,7 @@
sub_storage
:
{
sub_storage
:
{
type
:
"
mappingstorage2713
"
type
:
"
mappingstorage2713
"
},
},
map_all_
doc
: true,
map_all_
property
:
true
,
mapping_dict
:
{
mapping_dict
:
{
"
title
"
:
{
"
equal
"
:
"
otherTitle
"
},
"
title
"
:
{
"
equal
"
:
"
otherTitle
"
},
"
id
"
:
{
"
equal
"
:
"
otherId
"
}
"
id
"
:
{
"
equal
"
:
"
otherId
"
}
...
@@ -848,8 +848,28 @@
...
@@ -848,8 +848,28 @@
return
true
;
return
true
;
};
};
Storage2713.prototype.bulk = function () {
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
deepEqual(arguments, ["some", "arguments"], "bulk 2713 called");
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
[
return
[
{
{
"
otherId
"
:
"
foo
"
,
"
otherId
"
:
"
foo
"
,
...
@@ -863,7 +883,13 @@
...
@@ -863,7 +883,13 @@
];
];
};
};
jio.bulk("some", "arguments")
jio
.
bulk
([{
method
:
"
get
"
,
parameter_list
:
[
"
id1
"
]
},
{
method
:
"
get
"
,
parameter_list
:
[
"
id2
"
]
}])
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
deepEqual
(
deepEqual
(
result
,
result
,
...
@@ -882,7 +908,7 @@
...
@@ -882,7 +908,7 @@
.
always
(
function
()
{
.
always
(
function
()
{
start
();
start
();
});
});
});
*/
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// mappingStorage.repair
// 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