Liking cljdoc? Tell your friends :D

wagoe.audience.shell.persistence

Database persistence for audience definitions and memberships.

Implements IAudienceRepository using next.jdbc + HoneySQL.

Column layout for audience_segments: audience_id VARCHAR — keyword name (e.g. "premium-users") filters TEXT/JSONB — serialised as JSON tags TEXT/JSONB — serialised as JSON composition TEXT/JSONB — optional, serialised as JSON cache_config TEXT/JSONB — optional, serialised as JSON

JSON columns use cheshire for serialisation. On PostgreSQL the columns are JSONB; on H2 (tests) they are stored as TEXT — both are handled by ->json below.

Database persistence for audience definitions and memberships.

Implements IAudienceRepository using next.jdbc + HoneySQL.

Column layout for audience_segments:
  audience_id  VARCHAR — keyword name (e.g. "premium-users")
  filters      TEXT/JSONB — serialised as JSON
  tags         TEXT/JSONB — serialised as JSON
  composition  TEXT/JSONB — optional, serialised as JSON
  cache_config TEXT/JSONB — optional, serialised as JSON

JSON columns use cheshire for serialisation.  On PostgreSQL the
columns are JSONB; on H2 (tests) they are stored as TEXT — both
are handled by `->json` below.
raw docstring

clear-memberships!clj

(clear-memberships! datasource audience-id)

Delete all membership records for the given audience.

Args: datasource - javax.sql.DataSource audience-id - keyword

Returns: nil

Delete all membership records for the given audience.

Args:
  datasource  - javax.sql.DataSource
  audience-id - keyword

Returns:
  nil
sourceraw docstring

create-audience-storeclj

(create-audience-store datasource)

Create an AudienceStore backed by a JDBC datasource.

Args: datasource - javax.sql.DataSource (HikariCP pool or plain)

Returns: AudienceStore implementing IAudienceRepository

Create an AudienceStore backed by a JDBC datasource.

Args:
  datasource - javax.sql.DataSource (HikariCP pool or plain)

Returns:
  AudienceStore implementing IAudienceRepository
sourceraw docstring

get-membershipsclj

(get-memberships datasource audience-id)

Return all user UUIDs that are members of the given audience.

Args: datasource - javax.sql.DataSource audience-id - keyword

Returns: Vector of java.util.UUID, or [] if the segment does not exist

Return all user UUIDs that are members of the given audience.

Args:
  datasource  - javax.sql.DataSource
  audience-id - keyword

Returns:
  Vector of java.util.UUID, or [] if the segment does not exist
sourceraw docstring

save-memberships!clj

(save-memberships! datasource audience-id user-ids)

Batch-insert user UUIDs into audience_memberships for an audience.

Idempotent: one SELECT fetches the audience's existing user-ids, the already-present ids are removed in memory, and only the missing ones are inserted via chunked multi-row INSERTs — all inside a single transaction. This keeps the SQL portable across H2 and PostgreSQL (no ON CONFLICT) and avoids per-user round-trips.

Args: datasource - javax.sql.DataSource audience-id - keyword (e.g. :premium-users) user-ids - collection of java.util.UUID

Returns: nil

Batch-insert user UUIDs into audience_memberships for an audience.

Idempotent: one SELECT fetches the audience's existing user-ids, the
already-present ids are removed in memory, and only the missing ones are
inserted via chunked multi-row INSERTs — all inside a single transaction.
This keeps the SQL portable across H2 and PostgreSQL (no ON CONFLICT)
and avoids per-user round-trips.

Args:
  datasource  - javax.sql.DataSource
  audience-id - keyword (e.g. :premium-users)
  user-ids    - collection of java.util.UUID

Returns:
  nil
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close