Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
b07c5b5b
Commit
b07c5b5b
authored
Apr 16, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indices added to indexedDB description
parent
17965461
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
9 deletions
+59
-9
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+59
-9
No files found.
src/jio.storage/indexeddbstorage.js
View file @
b07c5b5b
...
@@ -13,12 +13,14 @@
...
@@ -13,12 +13,14 @@
*
*
* {
* {
* "type": "indexeddb",
* "type": "indexeddb",
* "database": <string>
* "database": <string>,
* "version": <number>, (default is `1`)
* "indices": <array of strings>
* }
* }
*
*
* The database name will be prefixed by "jio:", so if the database property is
* The database name will be prefixed by "jio:", so if the database property is
* "hello", then you can manually reach this database with
* "hello", then you can manually reach this database with
* `indexedDB.open("jio:hello");`. (Or
* `indexedDB.open("jio:hello"
, <version>
);`. (Or
* `indexedDB.deleteDatabase("jio:hello");`.)
* `indexedDB.deleteDatabase("jio:hello");`.)
*
*
* For more informations:
* For more informations:
...
@@ -78,25 +80,73 @@
...
@@ -78,25 +80,73 @@
"
must be a non-empty string
"
);
"
must be a non-empty string
"
);
}
}
this
.
_database_name
=
"
jio:
"
+
description
.
database
;
this
.
_database_name
=
"
jio:
"
+
description
.
database
;
if
(
Array
.
isArray
(
description
.
indices
))
{
this
.
_indices
=
description
.
indices
;
}
else
{
this
.
_indices
=
[];
}
var
i
,
l
,
index
;
for
(
i
=
0
,
l
=
this
.
_indices
.
length
;
i
<
l
;
i
+=
1
)
{
index
=
this
.
_indices
[
i
];
if
(
typeof
index
!==
"
string
"
||
index
===
""
)
{
throw
new
TypeError
(
"
IndexedDBStorage 'indices' must be an
"
+
"
array of non empty strings.
"
);
}
}
}
}
// XXX doc string
// XXX doc string
function
openRequestOnUpgradeNeeded
(
shared
,
event
)
{
function
openRequestOnUpgradeNeeded
(
shared
,
event
)
{
if
(
shared
.
aborted
)
{
return
;
}
if
(
shared
.
aborted
)
{
return
;
}
shared
.
db
=
event
.
target
.
result
;
shared
.
db
=
event
.
target
.
result
;
try
{
try
{
try
{
shared
.
store
=
shared
.
db
.
createObjectStore
(
"
metadata
"
,
{
shared
.
store
=
shared
.
db
.
createObjectStore
(
"
metadata
"
,
{
"
keyPath
"
:
"
_id
"
"
keyPath
"
:
"
_id
"
//"autoIncrement": true
//"autoIncrement": true
});
});
}
catch
(
e0
)
{
// store already exists
shared
.
store
=
event
.
target
.
transaction
.
objectStore
(
"
metadata
"
);
}
// `createObjectStore` can throw InvalidStateError - open_req.onerror
// `createObjectStore` can throw InvalidStateError - open_req.onerror
// and db.onerror won't be called.
// and db.onerror won't be called.
try
{
shared
.
store
.
createIndex
(
"
_id
"
,
"
_id
"
);
shared
.
store
.
createIndex
(
"
_id
"
,
"
_id
"
);
// `store.createIndex` can throw an error
// `store.createIndex` can throw an error
shared
.
db_created
=
true
;
}
catch
(
ignore
)
{
// index already exists
}
var
i
,
l
,
index
;
for
(
i
=
0
,
l
=
shared
.
connector
.
_indices
.
length
;
i
<
l
;
i
+=
1
)
{
index
=
shared
.
connector
.
_indices
[
i
];
try
{
shared
.
store
.
createIndex
(
index
,
index
);
}
catch
(
ignore
)
{
// index already exist
}
}
try
{
shared
.
store
=
shared
.
db
.
createObjectStore
(
"
attachment
"
,
{
"
keyPath
"
:
[
"
id
"
,
"
attachment
"
]
});
}
catch
(
ignore
)
{
// store already exists
}
try
{
shared
.
store
.
createIndex
(
"
id,attachment
"
,
[
"
id
"
,
"
attachment
"
]);
}
catch
(
ignore
)
{
// index already exist
}
shared
.
store
.
transaction
.
oncomplete
=
function
()
{
shared
.
store
.
transaction
.
oncomplete
=
function
()
{
delete
shared
.
store
;
delete
shared
.
store
;
};
};
shared
.
db_created
=
true
;
}
catch
(
e
)
{
}
catch
(
e
)
{
shared
.
reject
(
e
);
shared
.
reject
(
e
);
shared
.
db
.
close
();
shared
.
db
.
close
();
...
...
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