I'm very new with Dexie.js and Promises, so, bear with me.
How could I get an entity inside a Map function? I have the following method that's responsible to do a data source lookup within my IndexedDB.
function MapData(data) {
let mappedItems = {
items : data.messages.map(function(message) {
let contact = DataBase.GetContact(message.from);
return {
id: message.id,
dataType: message.messageType,
dataFrom: contact.name,
dataImg: contact.photo,
dataDate: TimestampToFormatedDate(message.date),
dataContent : {
title : message.content.subject,
content: message.content.content,
fileList: message.content.fileList,
participants: message.participants.map(function (participant) {
return ({ name: DataBase.GetContact(participant).name })
})
}
};
})
};
return mappedItems;
}
In the method DataBase.GetContact, I'd like to connect to database (IndexedDB), search the entity by the id, return it (the object from IndexedDB) and then use the object result to get its values while mapping.