Skip to content

Instantly share code, notes, and snippets.

@tarang9211
Created December 14, 2018 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarang9211/25999b1b8a7528de090825f691c504aa to your computer and use it in GitHub Desktop.
Save tarang9211/25999b1b8a7528de090825f691c504aa to your computer and use it in GitHub Desktop.
/** 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) {}
@tarang9211
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment