Skip to content

Instantly share code, notes, and snippets.

@sudomann
Last active December 25, 2020 20:02
Show Gist options
  • Save sudomann/77e0316a6ec74db9c8d999407c980e8b to your computer and use it in GitHub Desktop.
Save sudomann/77e0316a6ec74db9c8d999407c980e8b to your computer and use it in GitHub Desktop.
/**
* ETL function to gather all person type contacts from device
* @returns {Promise<{ name: string, nickname: string, maidenName: string, phoneNumbers: string[], emails: string[] }[]>} An promise resolved to an array of 0 or more transformed contacts
*/
export const extractAndTransformContacts = async () =>
Contacts.getContactsAsync({
fields: QUERY_FIELDS,
pageSize: 0,
}).then(({ data }) => {
const transformedContacts = produceContacts(data);
console.log('all contacts:', transformedContacts);
return transformedContacts;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment