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 }
);
});