Skip to content

Instantly share code, notes, and snippets.

@EduardoRodriguesF
Created May 27, 2022 17:51
Show Gist options
  • Save EduardoRodriguesF/83e550b78ed8ac7804becf010cd4ae4b to your computer and use it in GitHub Desktop.
Save EduardoRodriguesF/83e550b78ed8ac7804becf010cd4ae4b to your computer and use it in GitHub Desktop.
Gets many entries from VTEX MasterData and deletes all of it. (max of 100 entries per call) - DO NOT USE IT ON FRONT-END, IT WAS MADE TO USE IN DEVTOOLS WHEN NEEDED.
function deleteManyEntries(dataEntity, appKey, appToken) {
const headers = {
'X-VTEX-API-AppKey': appKey,
'X-VTEX-API-AppToken': appToken,
}
$.ajax({
url: `/api/dataentities/${dataEntity}/scroll?_fields=id`,
headers,
success: function(data) {
console.log('>>>>>> data to be deleted', data);
data.forEach(({ id }) => {
console.log('>>> id to delete', id);
$.ajax({
url: `/api/dataentities/${dataEntity}/documents/${id}`,
headers,
type: 'DELETE',
success: () => console.log('> deleted', id),
})
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment