Use IndexablePresence for hasFileAttachments and hasVisualMediaAttachments

Reduces index size, makes it easier to debug using IndexedDB inspector, and
hopefully improves lookup performance.
This commit is contained in:
Daniel Gasienica 2018-04-25 14:15:06 -04:00
parent 3a33d862c0
commit f36f206a01
9 changed files with 32 additions and 24 deletions

View file

@ -1,15 +1,18 @@
exports.run = (transaction) => {
const messagesStore = transaction.objectStore('messages');
[
console.log("Create message attachment metadata index: 'hasAttachments'");
messagesStore.createIndex(
'hasAttachments',
'hasVisualMediaAttachments',
'hasFileAttachments',
].forEach((name) => {
['conversationId', 'hasAttachments', 'received_at'],
{ unique: false }
);
['hasVisualMediaAttachments', 'hasFileAttachments'].forEach((name) => {
console.log(`Create message attachment metadata index: '${name}'`);
messagesStore.createIndex(
name,
['conversationId', name, 'received_at'],
['conversationId', 'received_at', name],
{ unique: false }
);
});

View file

@ -25,9 +25,8 @@ const PRIVATE = 'private';
// Version 5
// - Attachments: Track number and kind of attachments for media gallery
// - `hasAttachments?: 1 | 0`
// - `hasVisualMediaAttachments?: 1 | 0` (for media gallery Media view)
// - `hasFileAttachments?: 1 | 0` (for media gallery Documents view)
// - `hasVisualMediaAttachments?: 1 | undefined` (for media gallery Media view)
// - `hasFileAttachments?: 1 | undefined` (for media gallery Documents view)
const INITIAL_SCHEMA_VERSION = 0;