Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why delete-related functions are located in handlers file? #309

Open
FreePhoenix888 opened this issue Feb 15, 2024 · 0 comments
Open

Why delete-related functions are located in handlers file? #309

FreePhoenix888 opened this issue Feb 15, 2024 · 0 comments
Labels
question Further information is requested

Comments

@FreePhoenix888
Copy link
Member

export async function deleteId(id: number, options: {
table?: string;
returning?: string;
variables?: any;
name?: string;
} = { table: 'links' })
{
await deleteIds([id], options);
}
export async function deleteIds(ids: number[], options: {
table?: string;
returning?: string;
variables?: any;
name?: string;
} = { table: 'links' }) {
// return await deep.delete(ids, options); // should work, but doesn't
const idsFiltered = ids?.filter(linkId => typeof linkId === 'number');
if (idsFiltered?.length > 0) {
// log(`${options.table}, deleteIds[0..${idsFiltered.length}]: ${idsFiltered.join(', ')}`);
try
{
return await deep.delete(idsFiltered, options as any);
}
catch (e)
{
console.error(`Error deleting ids: ${idsFiltered.join(', ')}`, JSON.stringify(e, null, 2));
}
} else {
return { data: [] };
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant