View Source EctoFoundationDB.Tenant (Ecto.Adapters.FoundationDB v0.1.2)

This module allows the application to manage the creation and deletion of tenants within the FoundationDB database. All transactions require a tenant, so any application that uses the Ecto FoundationDB Adapter must use this module.

Summary

Functions

Clear all data for the given tenant. This cannot be undone.

Clears data in a tenant and then deletes it. If the tenant doesn't exist, no-op.

Create a tenant in the database.

Deletes a tenant from the database permanently. The tenant must have no data.

If the tenant doesn't exist, create it. Otherwise, no-op.

Returns true if the tenant already exists in the database.

Returns true if the tenant exists in the database. False otherwise.

List all tenants in the database. Could be expensive.

Open a tenant with a repo. With the result returned by this function, the caller can do database operations on the tenant's portion of the key-value store.

Open a tenant. With the result returned by this function, the caller can do database operations on the tenant's portion of the key-value store.

Helper function to ensure the given tenant exists and then clear it of all data, and finally return an open handle. Useful in test code, but in production, this would be dangerous.

Types

Functions

@spec clear(Ecto.Repo.t(), id()) :: :ok

Clear all data for the given tenant. This cannot be undone.

@spec clear_delete!(Ecto.Repo.t(), id()) :: :ok

Clears data in a tenant and then deletes it. If the tenant doesn't exist, no-op.

@spec create(Ecto.Repo.t(), id()) :: :ok

Create a tenant in the database.

Link to this function

db_open(db, id, options)

View Source
Link to this function

db_open!(db, id, options)

View Source
@spec delete(Ecto.Repo.t(), id()) :: :ok

Deletes a tenant from the database permanently. The tenant must have no data.

Link to this function

ensure_created(db, id, options)

View Source
@spec ensure_created(
  EctoFoundationDB.Database.t(),
  id(),
  EctoFoundationDB.Options.t()
) :: :ok

If the tenant doesn't exist, create it. Otherwise, no-op.

@spec exists?(Ecto.Repo.t(), id()) :: boolean()

Returns true if the tenant already exists in the database.

Link to this function

exists?(db, id, options)

View Source

Returns true if the tenant exists in the database. False otherwise.

@spec list(Ecto.Repo.t()) :: [id()]

List all tenants in the database. Could be expensive.

Link to this function

open(repo, id, options \\ [])

View Source
@spec open(Ecto.Repo.t(), id(), EctoFoundationDB.Options.t()) :: t()

Open a tenant with a repo. With the result returned by this function, the caller can do database operations on the tenant's portion of the key-value store.

The tenant must already exist.

When opening tenants with a repo, all migrations are automatically performed. This can cause open/2 to take a significant amount of time. Tenants can be kept open indefinitely, with any number of database transactions issued upon them.

Link to this function

open!(repo, id, options \\ [])

View Source
@spec open!(Ecto.Repo.t(), id(), EctoFoundationDB.Options.t()) :: t()

Open a tenant. With the result returned by this function, the caller can do database operations on the tenant's portion of the key-value store.

If the tenant does not exist, it is created.

When opening tenants with a repo, all migrations are automatically performed. This can cause open/2 to take a significant amount of time. Tenants can be kept open indefinitely, with any number of database transactions issued upon them.

Link to this function

open_empty!(repo, id, options_in \\ [])

View Source
@spec open_empty!(Ecto.Repo.t(), id(), EctoFoundationDB.Options.t()) :: t()

Helper function to ensure the given tenant exists and then clear it of all data, and finally return an open handle. Useful in test code, but in production, this would be dangerous.