Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3353682
D7122.id24363.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
987 B
Referenced Files
None
Subscribers
None
D7122.id24363.diff
View Options
diff --git a/web/database/queries/draft-queries.js b/web/database/queries/draft-queries.js
new file mode 100644
--- /dev/null
+++ b/web/database/queries/draft-queries.js
@@ -0,0 +1,36 @@
+// @flow
+
+import type { SqliteDatabase } from 'sql.js';
+
+function removeAllDrafts(db: SqliteDatabase) {
+ db.exec(`DELETE FROM drafts`);
+}
+
+function updateDraft(db: SqliteDatabase, key: string, text: string) {
+ const query = `
+ INSERT OR REPLACE INTO drafts (key, text)
+ VALUES ($key, $text)
+ `;
+ const params = {
+ $key: key,
+ $text: text,
+ };
+
+ db.exec(query, params);
+}
+
+function moveDraft(db: SqliteDatabase, oldKey: string, newKey: string) {
+ const query = `
+ UPDATE OR REPLACE drafts
+ SET key = $newKey, text = (SELECT text FROM drafts WHERE key = $oldKey)
+ WHERE key = $oldKey
+ `;
+ const params = {
+ $newKey: newKey,
+ $oldKey: oldKey,
+ };
+
+ db.exec(query, params);
+}
+
+export { removeAllDrafts, updateDraft, moveDraft };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 10:54 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574680
Default Alt Text
D7122.id24363.diff (987 B)
Attached To
Mode
D7122: [web-db] implement Draft Store Operations
Attached
Detach File
Event Timeline
Log In to Comment