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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
9260a30f
Commit
9260a30f
authored
Jun 30, 2017
by
Aurel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vincent-mapping' into nodejs-romain
parents
dd733b1d
74d8752d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+10
-7
test/jio.storage/mappingstorage.tests.js
test/jio.storage/mappingstorage.tests.js
+8
-3
No files found.
src/jio.storage/mappingstorage.js
View file @
9260a30f
...
@@ -10,6 +10,12 @@
...
@@ -10,6 +10,12 @@
if
(
storage
.
_no_sub_query_id
)
{
if
(
storage
.
_no_sub_query_id
)
{
throw
new
jIO
.
util
.
jIOError
(
'
no sub query id active
'
,
404
);
throw
new
jIO
.
util
.
jIOError
(
'
no sub query id active
'
,
404
);
}
}
if
(
value
===
undefined
)
{
throw
new
jIO
.
util
.
jIOError
(
'
can not find document with
'
+
key
+
'
: undefined
'
,
404
);
}
query
=
new
SimpleQuery
({
query
=
new
SimpleQuery
({
key
:
key
,
key
:
key
,
value
:
value
,
value
:
value
,
...
@@ -30,13 +36,13 @@
...
@@ -30,13 +36,13 @@
"
limit
"
:
storage
.
_query
.
limit
"
limit
"
:
storage
.
_query
.
limit
})
})
.
push
(
function
(
data
)
{
.
push
(
function
(
data
)
{
if
(
data
.
data
.
rows
.
length
===
0
)
{
if
(
data
.
data
.
total_rows
===
0
)
{
throw
new
jIO
.
util
.
jIOError
(
throw
new
jIO
.
util
.
jIOError
(
"
Can not find
id
"
,
"
Can not find
document with (
"
+
key
+
"
,
"
+
value
+
"
)
"
,
404
404
);
);
}
}
if
(
data
.
data
.
rows
.
length
>
1
)
{
if
(
data
.
data
.
total_rows
>
1
)
{
throw
new
TypeError
(
"
id must be unique field:
"
+
key
throw
new
TypeError
(
"
id must be unique field:
"
+
key
+
"
, result:
"
+
data
.
data
.
rows
.
toString
());
+
"
, result:
"
+
data
.
data
.
rows
.
toString
());
}
}
...
@@ -63,9 +69,6 @@
...
@@ -63,9 +69,6 @@
doc
.
hasOwnProperty
(
storage
.
_property_for_sub_id
))
{
doc
.
hasOwnProperty
(
storage
.
_property_for_sub_id
))
{
return
doc
[
storage
.
_property_for_sub_id
];
return
doc
[
storage
.
_property_for_sub_id
];
}
}
if
(
doc
.
hasOwnProperty
(
args
))
{
return
doc
[
args
];
}
}
}
return
getSubIdEqualSubProperty
(
storage
,
id
,
storage
.
_map_id
[
1
]);
return
getSubIdEqualSubProperty
(
storage
,
id
,
storage
.
_map_id
[
1
]);
},
},
...
@@ -342,7 +345,7 @@
...
@@ -342,7 +345,7 @@
if
(
this
.
_property_for_sub_id
&&
id
!==
undefined
)
{
if
(
this
.
_property_for_sub_id
&&
id
!==
undefined
)
{
return
this
.
_sub_storage
.
put
(
id
,
sub_doc
);
return
this
.
_sub_storage
.
put
(
id
,
sub_doc
);
}
}
if
(
!
this
.
_id_mapped
||
doc
[
this
.
_id_mapped
]
!==
undefined
)
{
if
(
this
.
_id_mapped
&&
doc
[
this
.
_id_mapped
]
!==
undefined
)
{
return
getSubStorageId
(
storage
,
id
,
doc
)
return
getSubStorageId
(
storage
,
id
,
doc
)
.
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
);
...
...
test/jio.storage/mappingstorage.tests.js
View file @
9260a30f
...
@@ -654,7 +654,7 @@
...
@@ -654,7 +654,7 @@
test
(
"
with id equalSubProperty and id in doc
"
,
function
()
{
test
(
"
with id equalSubProperty and id in doc
"
,
function
()
{
stop
();
stop
();
expect
(
3
);
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
type
:
"
mapping
"
,
...
@@ -664,9 +664,14 @@
...
@@ -664,9 +664,14 @@
}
}
});
});
Storage2713
.
prototype
.
buildQuery
=
function
(
options
)
{
equal
(
options
.
query
,
'
otherId: "bar"
'
,
"
allDoc 2713 called
"
);
return
[];
};
Storage2713
.
prototype
.
post
=
function
(
doc
)
{
Storage2713
.
prototype
.
post
=
function
(
doc
)
{
deepEqual
(
doc
,
{
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
},
"
post 2713 called
"
);
deepEqual
(
doc
,
{
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
},
"
post 2713 called
"
);
return
"
42
"
;
return
"
bar
"
;
};
};
Storage2713
.
prototype
.
put
=
function
(
id
,
doc
)
{
Storage2713
.
prototype
.
put
=
function
(
id
,
doc
)
{
...
@@ -675,7 +680,7 @@
...
@@ -675,7 +680,7 @@
"
title
"
:
"
foo
"
,
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
"
otherId
"
:
"
bar
"
},
"
put 2713 called
"
);
},
"
put 2713 called
"
);
return
"
42
"
;
return
"
bar
"
;
};
};
jio
.
post
({
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
})
jio
.
post
({
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
})
...
...
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