# persistence

class polyfactory.persistence.SyncPersistenceProtocol

  Bases: `Protocol`[`T`]

  Protocol for sync persistence

  save(data: T) → T

    Persist a single instance synchronously.

    Parameters:

      data – A single instance to persist.

    Returns:

      The persisted result.

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

    Persist multiple instances synchronously.

    Parameters:

      data – A list of instances to persist.

    Returns:

      The persisted result

  __init__(*args, **kwargs)

class polyfactory.persistence.AsyncPersistenceProtocol

  Bases: `Protocol`[`T`]

  Protocol for async persistence

  async save(data: T) → T

    Persist a single instance asynchronously.

    Parameters:

      data – A single instance to persist.

    Returns:

      The persisted result.

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

    Persist multiple instances asynchronously.

    Parameters:

      data – A list of instances to persist.

    Returns:

      The persisted result

  __init__(*args, **kwargs)