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
c2ca42a6
Commit
c2ca42a6
authored
Apr 01, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allDocs prototype added for indexeddbstorage
parent
fd387ce6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
2 deletions
+54
-2
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+54
-2
No files found.
src/jio.storage/indexeddbstorage.js
View file @
c2ca42a6
...
...
@@ -88,10 +88,11 @@
// If we reach this point, the database is created.
// There is no way to cancel the operation from here.
// So let's continue.
var
db
=
request
.
result
;
db
.
createObjectStore
(
"
metadata
"
,
{
var
db
=
request
.
result
,
store
=
db
.
createObjectStore
(
"
metadata
"
,
{
"
keyPath
"
:
"
_id
"
});
store
.
createIndex
(
"
_id
"
,
"
_id
"
);
status
=
"
created
"
;
};
request
.
onerror
=
function
()
{
...
...
@@ -227,6 +228,57 @@
},
command
.
error
,
command
.
notify
);
};
IndexedDBStorage
.
prototype
.
getList
=
function
()
{
var
rows
=
[],
onCancel
,
request
=
indexedDB
.
open
(
this
.
_database_name
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
request
.
onsuccess
=
function
()
{
var
db
,
tx
,
store
,
index
,
indexrequest
;
db
=
request
.
result
;
tx
=
db
.
transaction
(
"
metadata
"
,
"
readonly
"
);
onCancel
=
function
()
{
tx
.
abort
();
db
.
close
();
};
store
=
tx
.
objectStore
(
"
metadata
"
);
index
=
store
.
index
(
"
_id
"
);
indexrequest
=
index
.
openCursor
();
indexrequest
.
onsuccess
=
function
()
{
var
cursor
=
indexrequest
.
result
;
if
(
cursor
)
{
// Called for each matching record.
rows
.
push
({
"
id
"
:
cursor
.
value
.
_id
,
"
doc
"
:
cursor
.
value
,
"
values
"
:
{}
});
cursor
.
continue
();
}
else
{
// No more matching records.
resolve
({
"
data
"
:
{
"
rows
"
:
rows
,
"
total_rows
"
:
rows
.
length
}});
db
.
close
();
}
};
};
request
.
onerror
=
function
()
{
reject
(
request
.
error
);
var
db
=
request
.
result
;
if
(
db
)
{
db
.
close
();
}
};
},
function
()
{
if
(
typeof
onCancel
===
"
function
"
)
{
onCancel
();
}
});
};
IndexedDBStorage
.
prototype
.
allDocs
=
function
(
command
,
param
,
option
)
{
/*jslint unparam: true */
this
.
createDBIfNecessary
().
then
(
this
.
getList
.
bind
(
this
)).
then
(
command
.
success
,
command
.
error
,
command
.
notify
);
};
jIO
.
addStorage
(
"
indexeddb
"
,
IndexedDBStorage
);
}));
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