Created
December 14, 2018 09:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Fetch all conferences */ | |
let selectConferencesQuery; | |
try { | |
selectConferencesQuery = await query( | |
'SELECT id, name, description, dates, tags, image FROM conferences' | |
); | |
} catch (e) {} | |
/** Fetch the count of subevents related to a conference */ | |
const conferenceIds = selectConferencesQuery.results.map( | |
result => result.id | |
); | |
try { | |
await Promise.all( | |
conferenceIds.map(async conferenceId => { | |
const countQuery = await query( | |
'SELECT COUNT(*) as count from conferences_subevents_mapping WHERE cid=?', | |
[conferenceId] | |
); | |
}) | |
); | |
} catch (e) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function is to get all the conferences. I do not need the list of subevents, I only need the count of it. I think with this method I will have to mutate the
selectedConferences.results
array and update the count manually. Is there a better suggestion?