Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3556378
D7123.id23985.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
866 B
Referenced Files
None
Subscribers
None
D7123.id23985.diff
View Options
diff --git a/web/database/queries/draft-queries.js b/web/database/queries/draft-queries.js
--- a/web/database/queries/draft-queries.js
+++ b/web/database/queries/draft-queries.js
@@ -1,5 +1,9 @@
// @flow
+import type { ClientDBDraftInfo } from 'lib/types/draft-types.js';
+
+import { parseSQLiteResult } from '../utils/db-utils.js';
+
function removeAllDrafts(db: SqliteDatabase) {
db.exec(`DELETE from drafts`);
}
@@ -31,4 +35,14 @@
db.exec(query, params);
}
-export { removeAllDrafts, updateDraft, moveDraft };
+function getAllDrafts(db: SqliteDatabase): ClientDBDraftInfo[] {
+ const rawDBResult = db.exec(`SELECT * FROM drafts`);
+ const dbResult = parseSQLiteResult<ClientDBDraftInfo>(rawDBResult);
+ if (!dbResult.length) {
+ return [];
+ }
+
+ return dbResult[0];
+}
+
+export { removeAllDrafts, updateDraft, moveDraft, getAllDrafts };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 11:39 PM (6 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2722100
Default Alt Text
D7123.id23985.diff (866 B)
Attached To
Mode
D7123: [web-db] implement function get all drafts from SQLite
Attached
Detach File
Event Timeline
Log In to Comment