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

Make query in get() optional to just fetch first row #35

Merged
merged 1 commit into from
Jul 25, 2023
Merged

Conversation

aaroncox
Copy link
Member

@aaroncox aaroncox commented Jul 25, 2023

Was working on a test script that utilized the Contract Kit and needed to load the data from the globals table on the eosio contract. This table only has one row and I just needed to load it.

In the current dev version, what I had to do was:

const table = contract.table('global')
return (await table.first(1).next())[0]

The syntax here was kinda messy and I just wanted one row - so my solution was to make the query parameter on the get call optional, which leads to:

const table = contract.table('global')
return await table.get()

Thoughts?

@aaroncox aaroncox merged commit 9b90b04 into dev Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant