wharfkit / contract

Access table data, create actions, and retrieve types for Antelope-based Smart Contracts
https://wharfkit.com
Other
1 stars 1 forks source link

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

Closed aaroncox closed 1 year ago

aaroncox commented 1 year ago

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?