Skip to content

Instantly share code, notes, and snippets.

@tarang9211 tarang9211/count.js
Created Dec 14, 2018

Embed
What would you like to do?
/** 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

This comment has been minimized.

Copy link
Owner Author

tarang9211 commented Dec 14, 2018

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
You can’t perform that action at this time.