Skip to main content

Function: addFarm()

addFarm(fdm, principal_id, b_name_farm, b_businessid_farm, b_address_farm, b_postalcode_farm): Promise<any>

Defined in: fdm-core/src/farm.ts:29

Alpha

Creates a new farm record and assigns the "owner" role to the specified principal.

This function starts a database transaction, generates a unique identifier for the new farm, inserts the farm details into the database, and then grants the given principal the owner role.

Parameters

fdm

any

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

principal_id

string

The identifier of the principal creating the farm.

b_name_farm

any

The name of the farm.

b_businessid_farm

any

The business identifier for the farm.

b_address_farm

any

The address of the farm.

b_postalcode_farm

any

The postal code associated with the farm.

Returns

Promise<any>

The generated unique identifier for the new farm.

Throws

If the transaction fails to create the farm record.