Function: getCurrentSoilData()
getCurrentSoilData(
fdm
,principal_id
,b_id
,timeframe?
):Promise
<CurrentSoilData
>
Defined in: fdm-core/src/soil.ts:343
Retrieves the last available value for each soil parameter for a specified field.
This function queries the database to find the most recent value for each soil parameter (e.g., a_p_al, a_p_cc, a_som_loi, etc.) within the soil analysis records associated with a given field. It also returns the a_id, b_sampling_date, and a_source for each retrieved value.
Parameters
fdm
any
The FDM instance providing the connection to the database. The instance can be created with createFdmServer.
principal_id
any
The identifier of the principal requesting the data.
b_id
any
The identifier of the field.
timeframe?
Optional timeframe to filter the soil analyses. Only analyses after timeframe.end
are excluded.
Returns
Promise
<CurrentSoilData
>
An object where each key is a soil parameter name and the value is an object containing the last available value, the a_id of the analysis record it was retrieved from, the b_sampling_date, and the a_source. Returns an empty object if no records are found.
Throws
If the principal lacks read permissions for the field or if the database query fails.