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
Tristan Cavelier
jio
Commits
8fa98134
Commit
8fa98134
authored
Apr 02, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove method added to indexeddbstorage
parent
dd400574
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+74
-0
No files found.
src/jio.storage/indexeddbstorage.js
View file @
8fa98134
...
@@ -227,6 +227,57 @@
...
@@ -227,6 +227,57 @@
});
});
};
};
// XXX doc string
IndexedDBStorage
.
prototype
.
removeMetadata
=
function
(
id
)
{
var
onCancel
,
open_req
=
indexedDB
.
open
(
this
.
_database_name
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
open_req
.
onerror
=
function
()
{
if
(
open_req
.
result
)
{
open_req
.
result
.
close
();
}
reject
(
open_req
.
error
);
};
open_req
.
onsuccess
=
function
()
{
// *Called at t + 1*
var
tx
,
store
,
db
=
open_req
.
result
;
try
{
tx
=
db
.
transaction
(
"
metadata
"
,
"
readwrite
"
);
tx
.
onerror
=
function
()
{
reject
(
tx
.
error
);
db
.
close
();
};
tx
.
oncomplete
=
function
()
{
// *Called at t + 3*
resolve
();
db
.
close
();
};
// we can cancel the transaction from here
onCancel
=
function
()
{
tx
.
abort
();
db
.
close
();
};
store
=
tx
.
objectStore
(
"
metadata
"
);
store
.
delete
(
id
);
// store.onsuccess = function () {
// // *Called at t + 2*
// };
}
catch
(
e
)
{
console
.
log
(
e
);
reject
(
e
);
db
.
close
();
}
};
},
function
()
{
if
(
typeof
onCancel
===
"
function
"
)
{
onCancel
();
}
});
};
// XXX doc string
IndexedDBStorage
.
prototype
.
removeAttachments
=
function
(
id
,
attachment_ids
)
{
/*jslint unparam: true */
return
new
Promise
(
function
(
done
)
{
done
();
});
};
// XXX doc string
// XXX doc string
IndexedDBStorage
.
prototype
.
get
=
function
(
command
,
param
)
{
IndexedDBStorage
.
prototype
.
get
=
function
(
command
,
param
)
{
this
.
createDBIfNecessary
().
this
.
createDBIfNecessary
().
...
@@ -265,6 +316,29 @@
...
@@ -265,6 +316,29 @@
},
command
.
error
,
command
.
notify
);
},
command
.
error
,
command
.
notify
);
};
};
// XXX doc string
IndexedDBStorage
.
prototype
.
remove
=
function
(
command
,
param
)
{
var
this_
=
this
;
this
.
createDBIfNecessary
().
then
(
this
.
getMetadata
.
bind
(
this
,
param
.
_id
)).
then
(
function
(
metadata
)
{
var
attachments
=
metadata
.
_attachments
,
promise
;
promise
=
this_
.
removeMetadata
(
param
.
_id
);
if
(
typeof
attachments
===
"
object
"
&&
attachments
!==
null
)
{
promise
.
then
(
function
(
answer
)
{
return
this_
.
removeAttachments
(
param
.
_id
,
Object
.
keys
(
attachments
)
).
then
(
null
,
function
()
{
return
;
}).
then
(
function
()
{
return
answer
;
});
});
}
return
promise
;
}).
then
(
command
.
success
,
command
.
error
,
command
.
notify
);
};
// XXX doc string
IndexedDBStorage
.
prototype
.
getList
=
function
()
{
IndexedDBStorage
.
prototype
.
getList
=
function
()
{
var
rows
=
[],
onCancel
,
open_req
=
indexedDB
.
open
(
this
.
_database_name
);
var
rows
=
[],
onCancel
,
open_req
=
indexedDB
.
open
(
this
.
_database_name
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
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