getHarvestsForFarm
@nmi-agro/fdm-source / fdm-core/src / getHarvestsForFarm
Function: getHarvestsForFarm()
getHarvestsForFarm(
fdm,principal_id,b_id_farm,timeframe?):Promise<Map<string,Harvest[]>>
Defined in: fdm-core/src/harvest.ts:359
Alpha
Retrieves all harvests for every cultivation on a farm.
Instead of issuing multiple queries per cultivation, this function performs a single
joined query across cultivationHarvesting, harvestables, harvestableSampling,
harvestableAnalyses, cultivationStarting, and fieldAcquiring so that all
harvest data for the farm is fetched at once.
A single farm-level permission check is performed instead of one per cultivation.
Parameters
fdm
PgDatabase
The FDM instance providing the connection to the database.
principal_id
any
The ID of the principal making the request.
b_id_farm
any
The ID of the farm.
timeframe?
Optional timeframe to filter by harvest date.
Returns
Promise<Map<string, Harvest[]>>
A Promise resolving to a Map keyed by cultivation ID (b_lu), with arrays of Harvest as values.