Handles synchronization of fixture records to the database.
The sync process:
- Resolves all relations (syncs dependencies first, collects their IDs)
- Prepares the record with resolved foreign keys
- Upserts the record based on search keys
- Syncs any nested fixtures with the parent's ID
Summary
Functions
Delete records from the database that are not in the synced list.
Sync a fixture module's records to the database.
Sync a single record.
Sync records with a given config.
Types
Functions
Delete records from the database that are not in the synced list.
@spec sync(module(), module(), Keyword.t()) :: sync_result() | sync_result_with_pruned()
Sync a fixture module's records to the database.
Options
:prune- iftrue, deletes records not in fixtures. Defaults tofalse.
Returns
{:ok, synced_records}- when prune is false{:ok, synced_records, deleted_records}- when prune is true{:error, reason}- on failure
@spec sync_record(map(), Sow.Config.t(), module()) :: {:ok, struct()} | {:error, term()}
Sync a single record.
@spec sync_records(map() | [map()], Sow.Config.t(), module()) :: sync_result()
Sync records with a given config.