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

Type error on transaction delete with const table name #1405

Open
tsg opened this issue Mar 11, 2024 · 0 comments
Open

Type error on transaction delete with const table name #1405

tsg opened this issue Mar 11, 2024 · 0 comments
Labels
bug Something isn't working needs-triage

Comments

@tsg
Copy link
Member

tsg commented Mar 11, 2024

Describe the bug

The transaction API requires the table name as const, but in a situation like this you get an error:

const records = await xata.db.test.getAll();
const toDelete = records.map(rec => {
    return {
        delete: {
            table: 'test',
            id: rec.id
        }
    }
})
const page = await xata.transactions.run(toDelete);
console.log(page);

The workaround is to do 'test' as const like this:

const records = await xata.db.test.getAll();
const toDelete = records.map(rec => {
    return {
        delete: {
            table: 'test' as const,
            id: rec.id
        }
    }
})
const page = await xata.transactions.run(toDelete);
console.log(page);

To avoid this issue, @SferaDev suggested that we could accept string & {} so that auto-complete still works.

@tsg tsg added the bug Something isn't working label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant