Skip to main content

resourcePropertyId

resourcePropertyId(oldId): (target, key) => void

The decorator lets you specify PropertyMeta.id.

This is typically needed because those identifiers are usually generated automatically from the property name. When a property is renamed the newly generated identifier (based on the new name) will differ and can break existing data, links, or integrations. In such cases you should look up the identifier currently stored in the ResourceProperty table and pass that identifier to the decorator so the PropertyMeta.id remains stable.

Example:

// Before renaming:
class Student {
firstName: string; // property id generated 'b3f1c8a2-5f7d-4e3b-8c2a-9d7f2c0a1b6e'
lastName: string;
}

// After renaming firstName -> givenName:
class Student {
@resourcePropertyId ('b3f1c8a2-5f7d-4e3b-8c2a-9d7f2c0a1b6e')
givenName: string; property id would be generated as '7a1f2e9c-3b4d-4f6a-9c8e-1b2a3d4c5e6f',
decorator {@link resourcePropertyId} preserves 'b3f1c8a2-5f7d-4e3b-8c2a-9d7f2c0a1b6e',
lastName: string;
}

Sets {@link PropertyMeta.resourcePropertyId}.

Parameters

oldId

string

The previous identifier for this property (copied from the database)

Returns

(target, key): void

Parameters

target

object

key

string

Returns

void