Skip to main content

Function: addField()

addField(fdm, principal_id, b_id_farm, b_name, b_id_source, b_geometry, b_start, b_acquiring_method, b_end?): Promise<any>

Defined in: fdm-core/src/field.ts:46

Alpha

Adds a new field to a farm.

This function verifies that the principal has write permission for the specified farm, generates a unique field ID, records the field details, and creates an association between the field and the farm. If a discarding date is provided, the function ensures that the acquiring date is earlier than the discarding date, throwing an error otherwise.

Parameters

fdm

any

The FDM instance providing the connection to the database. The instance can be created with createFdmServer.

principal_id

any

The unique identifier of the principal performing the operation.

b_id_farm

any

Identifier of the farm to which the field belongs.

b_name

any

Name of the field.

b_id_source

any

Identifier for the field in the source dataset.

b_geometry

any

GeoJSON representation of the field geometry.

b_start

any

The start date for managing the field.

b_acquiring_method

any

Method used for acquiring the field.

b_end?

any

(Optional) The end date for managing the field.

Returns

Promise<any>

A promise that resolves to the newly generated field ID.

Throws

If the acquiring date is not earlier than the discarding date.