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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
lucas.parsy
jio
Commits
0b0e0149
Commit
0b0e0149
authored
Dec 10, 2015
by
lucas.parsy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed useless table in websqlstorage
added indexes to increase queries speed.
parent
fbdd12ad
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
104 deletions
+83
-104
src/jio.storage/websqlstorage.js
src/jio.storage/websqlstorage.js
+13
-19
test/jio.storage/websqlstorage.tests.js
test/jio.storage/websqlstorage.tests.js
+70
-85
No files found.
src/jio.storage/websqlstorage.js
View file @
0b0e0149
...
@@ -55,21 +55,17 @@
...
@@ -55,21 +55,17 @@
"
CREATE TABLE IF NOT EXISTS document
"
+
"
CREATE TABLE IF NOT EXISTS document
"
+
"
(id VARCHAR PRIMARY KEY NOT NULL, data TEXT)
"
,
"
(id VARCHAR PRIMARY KEY NOT NULL, data TEXT)
"
,
"
CREATE TABLE IF NOT EXISTS attachment
"
+
"
CREATE TABLE IF NOT EXISTS attachment
"
+
"
(id VARCHAR, attachment VARCHAR,
"
+
"
CONSTRAINT uniq UNIQUE (id, attachment))
"
,
"
CREATE TABLE IF NOT EXISTS blob
"
+
"
(id VARCHAR, attachment VARCHAR, part INT, blob TEXT)
"
,
"
(id VARCHAR, attachment VARCHAR, part INT, blob TEXT)
"
,
"
CREATE TRIGGER IF NOT EXISTS remove
"
+
"
BEFORE DELETE ON document FOR EACH ROW BEGIN DELETE
"
+
"
FROM attachment WHERE id = OLD.id;END;
"
,
"
CREATE TRIGGER IF NOT EXISTS removeAttachment
"
+
"
CREATE TRIGGER IF NOT EXISTS removeAttachment
"
+
"
BEFORE DELETE ON attachment FOR EACH ROW
"
+
"
BEFORE DELETE ON document FOR EACH ROW
"
+
"
BEGIN DELETE from blob WHERE id = OLD.id
"
+
"
BEGIN DELETE from attachment WHERE id = OLD.id;END;
"
,
"
AND attachment = OLD.attachment;END;
"
"
CREATE INDEX IF NOT EXISTS index_document ON document (id);
"
,
"
CREATE INDEX IF NOT EXISTS index_attachment
"
+
"
ON attachment (id, attachment);
"
];
];
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
queueSql
(
db
,
query_list
,
[
[],
[],
[],
[],
[]
]);
return
queueSql
(
db
,
query_list
,
[]);
});
});
}
}
...
@@ -159,7 +155,7 @@
...
@@ -159,7 +155,7 @@
.
push
(
function
()
{
.
push
(
function
()
{
return
queueSql
(
db
,
[
return
queueSql
(
db
,
[
"
SELECT id FROM document WHERE id = ?
"
,
"
SELECT id FROM document WHERE id = ?
"
,
"
SELECT attachment FROM attachment WHERE id = ?
"
"
SELECT
DISTINCT
attachment FROM attachment WHERE id = ?
"
],
[[
id
],
[
id
]]);
],
[[
id
],
[
id
]]);
})
})
.
push
(
function
(
result_list
)
{
.
push
(
function
(
result_list
)
{
...
@@ -183,7 +179,7 @@
...
@@ -183,7 +179,7 @@
return
jIO
.
util
.
readBlobAsDataURL
(
blob
);
return
jIO
.
util
.
readBlobAsDataURL
(
blob
);
})
})
.
push
(
function
(
strBlob
)
{
.
push
(
function
(
strBlob
)
{
argument_list
[
index
+
3
].
push
(
strBlob
.
currentTarget
.
result
);
argument_list
[
index
+
2
].
push
(
strBlob
.
currentTarget
.
result
);
return
;
return
;
});
});
}
}
...
@@ -211,18 +207,16 @@
...
@@ -211,18 +207,16 @@
if
(
result
[
0
].
rows
.
length
===
0
)
{
if
(
result
[
0
].
rows
.
length
===
0
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot access subdocument
"
,
404
);
throw
new
jIO
.
util
.
jIOError
(
"
Cannot access subdocument
"
,
404
);
}
}
query_list
.
push
(
"
INSERT OR REPLACE INTO attachment(id, attachment)
"
+
query_list
.
push
(
"
DELETE FROM attachment WHERE id = ?
"
+
"
VALUES(?, ?)
"
);
"
AND attachment = ?
"
);
argument_list
.
push
([
id
,
name
]);
argument_list
.
push
([
id
,
name
]);
query_list
.
push
(
"
DELETE FROM blob WHERE id = ? AND attachment = ?
"
);
query_list
.
push
(
"
INSERT INTO attachment(id, attachment, part, blob)
"
+
argument_list
.
push
([
id
,
name
]);
query_list
.
push
(
"
INSERT INTO blob(id, attachment, part, blob)
"
+
"
VALUES(?, ?, ?, ?)
"
);
"
VALUES(?, ?, ?, ?)
"
);
argument_list
.
push
([
id
,
name
,
-
1
,
argument_list
.
push
([
id
,
name
,
-
1
,
blob
.
type
||
"
application/octet-stream
"
]);
blob
.
type
||
"
application/octet-stream
"
]);
for
(
i
=
0
,
index
=
0
;
i
<
blob_size
;
i
+=
part_size
,
index
+=
1
)
{
for
(
i
=
0
,
index
=
0
;
i
<
blob_size
;
i
+=
part_size
,
index
+=
1
)
{
query_list
.
push
(
"
INSERT INTO
blob
(id, attachment, part, blob)
"
+
query_list
.
push
(
"
INSERT INTO
attachment
(id, attachment, part, blob)
"
+
"
VALUES(?, ?, ?, ?)
"
);
"
VALUES(?, ?, ?, ?)
"
);
argument_list
.
push
([
id
,
name
,
index
]);
argument_list
.
push
([
id
,
name
,
index
]);
sendBlobPart
(
blob
.
slice
(
i
,
i
+
part_size
),
argument_list
,
index
,
sendBlobPart
(
blob
.
slice
(
i
,
i
+
part_size
),
argument_list
,
index
,
...
@@ -269,7 +263,7 @@
...
@@ -269,7 +263,7 @@
return
that
.
_init_db_promise
;
return
that
.
_init_db_promise
;
})
})
.
push
(
function
()
{
.
push
(
function
()
{
var
command
=
"
SELECT part, blob FROM
blob
WHERE id = ? AND
"
+
var
command
=
"
SELECT part, blob FROM
attachment
WHERE id = ? AND
"
+
"
attachment = ? AND part >= ?
"
,
"
attachment = ? AND part >= ?
"
,
argument_list
=
[
id
,
name
,
start_index
];
argument_list
=
[
id
,
name
,
start_index
];
...
...
test/jio.storage/websqlstorage.tests.js
View file @
0b0e0149
This diff is collapsed.
Click to expand it.
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