persistence

class polyfactory.persistence.SyncPersistenceProtocol[source]

Bases: Protocol[T]

Protocol for sync persistence

save(data: T) T[source]

Persist a single instance synchronously.

Parameters:

data – A single instance to persist.

Returns:

The persisted result.

save_many(data: list[T]) list[T][source]

Persist multiple instances synchronously.

Parameters:

data – A list of instances to persist.

Returns:

The persisted result

__init__(*args, **kwargs)
class polyfactory.persistence.AsyncPersistenceProtocol[source]

Bases: Protocol[T]

Protocol for async persistence

async save(data: T) T[source]

Persist a single instance asynchronously.

Parameters:

data – A single instance to persist.

Returns:

The persisted result.

async save_many(data: list[T]) list[T][source]

Persist multiple instances asynchronously.

Parameters:

data – A list of instances to persist.

Returns:

The persisted result

__init__(*args, **kwargs)