Skip to main content

Overview

useFetchEntityByForeignId returns a function that fetches an entity using the foreign ID from your system. Optionally auto-creates the entity if it does not yet exist.

Usage Example

Parameters

foreignId
string
required
The foreign ID to look up. This is the identifier from your own system.
createIfNotFound
boolean
If true, automatically creates a new entity with this foreign ID when one does not exist.
include
string | string[]
Optional. Populate related fields. Accepted values: "user", "space", "topComment", "saved", "files".

Returns

Entity
Entity
The fetched (or newly created) entity. See Entity data model.