Field<T> structs implement methods such as eq, gt, lt, etc., which return a Filter<T>, which, in turn, can be combined using and and or to produce a mode complex Filter<T>. Finally, a Filter<T> can be ordered ascending or descending, turning it into a QueryFragment<T>.
The find function on Entity takes a Filter or QueryFragment and fetches the corresponding object from the database, if any exists.
Testing steps
CI testing. This PR includes an integration test for added functionality.
Changelog
Add find(query: impl Into<QueryFragment<Self>>) -> Option<Self> to Entity.
Add ff_single_select to FFI, and single_select to the indexer.
Add fuel_indexer_plugin::find module, which contains the code for generating SQL query fragments.
Decoder now generates field_selectors, e.g., pub fn base_chain_height() -> Field<ChainInfo, U32> which are used to construct queries
Description
Closes https://github.com/FuelLabs/fuel-indexer/issues/1437.
Example usage:
This PR extends the codegen to generate field selectors for an
@entity
, e.g.:Field<T>
structs implement methods such aseq
,gt
,lt
, etc., which return aFilter<T>
, which, in turn, can be combined usingand
andor
to produce a mode complexFilter<T>
. Finally, aFilter<T>
can be ordered ascending or descending, turning it into aQueryFragment<T>
.The
find
function onEntity
takes aFilter
orQueryFragment
and fetches the corresponding object from the database, if any exists.Testing steps
CI testing. This PR includes an integration test for added functionality.
Changelog
find(query: impl Into<QueryFragment<Self>>) -> Option<Self>
toEntity
.ff_single_select
to FFI, andsingle_select
to the indexer.fuel_indexer_plugin::find
module, which contains the code for generating SQL query fragments.field_selectors
, e.g.,pub fn base_chain_height() -> Field<ChainInfo, U32>
which are used to construct queries