Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
Commits
4a08108d
Commit
4a08108d
authored
Sep 29, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mapping storage: add property include_docs and fix put
parent
6b695237
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
9 deletions
+28
-9
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+28
-9
No files found.
src/jio.storage/mappingstorage.js
View file @
4a08108d
...
...
@@ -14,7 +14,10 @@
option
.
query
=
this
.
_mapping_dict
.
id
.
equal
+
'
: "
'
+
index
+
'
"
'
;
return
this
.
_sub_storage
.
allDocs
(
option
)
.
push
(
function
(
data
)
{
if
(
data
.
data
.
rows
.
length
>
0
)
{
return
data
.
data
.
rows
[
0
].
id
;
}
return
undefined
;
});
};
...
...
@@ -51,7 +54,7 @@
};
MappingStorage
.
prototype
.
put
=
function
(
index
,
doc
)
{
var
prop
,
var
prop
,
that
=
this
,
doc_mapped
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
_default_dict
));
for
(
prop
in
doc
)
{
if
(
doc
.
hasOwnProperty
(
prop
))
{
...
...
@@ -63,10 +66,16 @@
return
this
.
_sub_storage
.
put
(
index
,
doc_mapped
);
}
doc_mapped
[
this
.
_mapping_dict
.
id
.
equal
]
=
index
;
return
this
.
_sub_storage
.
post
(
doc_mapped
)
return
this
.
_getSubStorageId
(
index
)
.
push
(
function
(
id
)
{
if
(
id
===
undefined
)
{
return
that
.
_sub_storage
.
post
(
doc_mapped
)
.
push
(
function
()
{
return
index
;
});
}
return
that
.
_sub_storage
.
put
(
id
,
doc_mapped
);
});
};
MappingStorage
.
prototype
.
remove
=
function
(
index
)
{
...
...
@@ -130,12 +139,15 @@
});
};
MappingStorage
.
prototype
.
hasCapacity
=
function
()
{
MappingStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
include_docs
"
)
{
return
true
;
}
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
MappingStorage
.
prototype
.
buildQuery
=
function
(
option
)
{
var
that
=
this
,
i
,
select_list
=
[],
sort_on
=
[],
query
;
var
that
=
this
,
i
,
select_list
=
[],
sort_on
=
[],
query
,
prop
;
function
mapQuery
(
one_query
)
{
var
i
,
query_list
=
[];
...
...
@@ -167,6 +179,14 @@
select_list
.
push
(
this
.
_mapping_dict
[
option
.
select_list
[
i
]].
equal
);
}
}
if
(
option
.
include_docs
)
{
select_list
=
[];
for
(
prop
in
this
.
_mapping_dict
)
{
if
(
this
.
_mapping_dict
.
hasOwnProperty
(
prop
))
{
select_list
.
push
(
this
.
_mapping_dict
[
prop
].
equal
);
}
}
}
if
(
this
.
_mapping_dict
.
id
!==
undefined
&&
this
.
_mapping_dict
.
id
.
equal
!==
"
id
"
)
{
select_list
.
push
(
this
.
_mapping_dict
.
id
.
equal
);
...
...
@@ -177,8 +197,7 @@
query
:
mapQuery
(
query
),
select_list
:
select_list
,
sort_on
:
sort_on
,
limit
:
option
.
limit
,
include_docs
:
option
.
include_docs
||
false
limit
:
option
.
limit
}
)
.
push
(
function
(
result
)
{
...
...
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