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
preetwinder
jio
Commits
64b99388
Commit
64b99388
authored
Apr 26, 2019
by
preetwinder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add index keys
parent
b08e246c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
516 additions
and
287 deletions
+516
-287
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+340
-287
test/jio.storage/indexeddbstorage.tests.js
test/jio.storage/indexeddbstorage.tests.js
+176
-0
No files found.
src/jio.storage/indexeddbstorage.js
View file @
64b99388
This diff is collapsed.
Click to expand it.
test/jio.storage/indexeddbstorage.tests.js
View file @
64b99388
...
@@ -49,6 +49,182 @@
...
@@ -49,6 +49,182 @@
});
});
}
}
function
idCompare
(
value1
,
value2
)
{
if
(
value1
.
id
>
value2
.
id
)
{
return
1
;
}
if
(
value1
.
id
<
value2
.
id
)
{
return
-
1
;
}
return
0
;
}
/////////////////////////////////////////////////////////////////
// indexedDBStorage.buildQuery
/////////////////////////////////////////////////////////////////
module
(
"
indexedDBStorage.buildQuery
"
,
{
teardown
:
function
()
{
deleteIndexedDB
(
this
.
jio
);
}
});
test
(
"
Simple query matching single object
"
,
function
()
{
var
context
=
this
;
context
.
jio
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
index2_test
"
,
index_keys
:
[
"
a
"
,
"
b
"
],
});
stop
();
expect
(
2
);
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
a: "3"
'
});
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
1
);
deepEqual
(
result
.
data
.
rows
,
[{
"
id
"
:
"
32
"
,
"
value
"
:
{}}]);
})
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
Simple query matching multiple objects
"
,
function
()
{
var
context
=
this
;
context
.
jio
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
index2_test
"
,
index_keys
:
[
"
a
"
,
"
b
"
],
});
stop
();
expect
(
2
);
RSVP
.
all
([
context
.
jio
.
put
(
"
32
"
,
{
a
:
"
3
"
,
b
:
"
1
"
}),
context
.
jio
.
put
(
"
21
"
,
{
a
:
"
8
"
,
b
:
"
1
"
}),
context
.
jio
.
put
(
"
3
"
,
{
a
:
"
5
"
,
b
:
"
1
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
b: "1"
'
});
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
.
total_rows
,
3
);
deepEqual
(
result
.
data
.
rows
.
sort
(
idCompare
),
[
{
"
id
"
:
"
32
"
,
"
value
"
:
{}},
{
"
id
"
:
"
21
"
,
"
value
"
:
{}},
{
"
id
"
:
"
3
"
,
"
value
"
:
{}}
].
sort
(
idCompare
));
})
.
fail
(
function
(
error
)
{
console
.
log
(
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
Index keys are modified
"
,
function
()
{
var
context
=
this
;
context
.
jio
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
index2_test
"
,
version
:
1
,
index_keys
:
[
"
a
"
]
});
stop
();
expect
(
7
);
RSVP
.
all
([
context
.
jio
.
put
(
"
32
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
inverse
"
}),
context
.
jio
.
put
(
"
5
"
,
{
"
a
"
:
"
6
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
strong
"
}),
context
.
jio
.
put
(
"
14
"
,
{
"
a
"
:
"
67
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
disolve
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
a: "67"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
,
[{
"
id
"
:
"
14
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
context
.
jio
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
index2_test
"
,
version
:
2
,
index_keys
:
[
"
a
"
,
"
b
"
,
"
c
"
],
});
})
.
then
(
function
()
{
return
RSVP
.
all
([
context
.
jio
.
put
(
"
18
"
,
{
"
a
"
:
"
2
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
align
"
}),
context
.
jio
.
put
(
"
62
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
2
"
,
"
c
"
:
"
disolve
"
})
]);
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
b: "3"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
,
[{
"
id
"
:
"
14
"
,
"
value
"
:
{}},
{
"
id
"
:
"
18
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
c: "disolve"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
,
[{
"
id
"
:
"
14
"
,
"
value
"
:
{}},
{
"
id
"
:
"
62
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
a: "3"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
,
[{
"
id
"
:
"
32
"
,
"
value
"
:
{}},
{
"
id
"
:
"
62
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
context
.
jio
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
index2_test
"
,
index_keys
:
[
"
a
"
,
"
c
"
],
version
:
3
});
})
.
then
(
function
()
{
return
context
.
jio
.
put
(
"
192
"
,
{
"
a
"
:
"
3
"
,
"
b
"
:
"
3
"
,
"
c
"
:
"
disolve
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
a: "3"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
.
sort
(
idCompare
),
[{
"
id
"
:
"
192
"
,
"
value
"
:
{}},
{
"
id
"
:
"
32
"
,
"
value
"
:
{}},
{
"
id
"
:
"
62
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
query
:
'
c: "disolve"
'
});
})
.
then
(
function
(
result
)
{
deepEqual
(
result
.
data
.
rows
.
sort
(
idCompare
),
[{
"
id
"
:
"
14
"
,
"
value
"
:
{}},
{
"
id
"
:
"
192
"
,
"
value
"
:
{}},
{
"
id
"
:
"
62
"
,
"
value
"
:
{}}]);
})
.
then
(
function
()
{
return
context
.
jio
.
allDocs
({
subquery
:
'
b: "3"
'
});
})
.
fail
(
function
(
error
)
{
equal
(
error
.
status_code
,
501
);
equal
(
error
.
message
,
"
Capacity 'query' is not implemented on 'indexeddb'
"
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// indexeddbStorage.constructor
// indexeddbStorage.constructor
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
...
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