Liking cljdoc? Tell your friends :D
Clojure only.

thoughtsforge.db-actions

DynamoDB Single Table Design Operations.

Performs operations on DynamoDB tables following the single table design pattern. Multiple entity types are stored in one table using composite primary keys (pk/sk) and GSIs to support various access patterns.

Key conventions:

  • pk, pk1, pk2, ... : Partition key columns (pk for main table, pk1+ for GSIs)
  • sk, sk1, sk2, ... : Sort key columns (sk for main table, sk1+ for GSIs)
  • GSI naming: gsiPk{n}Sk{m} (e.g., gsiPkSk1, gsiPk1Sk2)
  • creationTime: Automatically set on first insert (immutable)
  • updateTime: Automatically updated on every upsert
DynamoDB Single Table Design Operations.

Performs operations on DynamoDB tables following the single table design pattern.
Multiple entity types are stored in one table using composite primary keys (pk/sk)
and GSIs to support various access patterns.

Key conventions:
  - pk, pk1, pk2, ... : Partition key columns (pk for main table, pk1+ for GSIs)
  - sk, sk1, sk2, ... : Sort key columns (sk for main table, sk1+ for GSIs)
  - GSI naming: gsiPk{n}Sk{m} (e.g., gsiPkSk1, gsiPk1Sk2)
  - creationTime: Automatically set on first insert (immutable)
  - updateTime: Automatically updated on every upsert
raw docstring

deleteclj

(delete client
        table-name
        pk
        sk
        &
        {:keys [return-old-values] :or {return-old-values true}})

Deletes an item from a DynamoDB table by pk and sk.

Args: client - cognitect AWS client table-name - DynamoDB table name pk - partition key value (must not be nil) sk - sort key value (must not be nil)

Options: :return-old-values - if true, returns the deleted item's attributes (default true)

Returns the deleted item if return-old-values is true, nil otherwise. Returns nil when return-old-values is true and the item did not exist.

Deletes an item from a DynamoDB table by pk and sk.

Args:
  client     - cognitect AWS client
  table-name - DynamoDB table name
  pk         - partition key value (must not be nil)
  sk         - sort key value (must not be nil)

Options:
  :return-old-values - if true, returns the deleted item's attributes (default true)

Returns the deleted item if return-old-values is true, nil otherwise.
Returns nil when return-old-values is true and the item did not exist.
raw docstring

fetchclj

(fetch client
       table-name
       pk
       sk-match-value
       &
       {:keys [pk-index sk-index sort-direction limit pagination-token]
        :or {pk-index 0 sk-index 0 sort-direction :asc}})

Queries items in a DynamoDB table filtered by pk and begins_with on sk.

Args: client - cognitect AWS client (aws/client {:api :dynamodb}) table-name - DynamoDB table name pk - partition key value (must not be nil) sk-match-value - prefix matched against the sort key (begins_with, must not be nil)

Options: :pk-index - partition key index, 0 = main table pk (default 0) :sk-index - sort key index, 0 = main table sk (default 0) :sort-direction - :asc or :desc (default :asc) :limit - max number of items to return (must be positive) :pagination-token - token from a previous response to fetch the next page

Returns a map with :items (vector) and optionally :pagination-token.

Queries items in a DynamoDB table filtered by pk and begins_with on sk.

Args:
  client         - cognitect AWS client (aws/client {:api :dynamodb})
  table-name     - DynamoDB table name
  pk             - partition key value (must not be nil)
  sk-match-value - prefix matched against the sort key (begins_with, must not be nil)

Options:
  :pk-index         - partition key index, 0 = main table pk (default 0)
  :sk-index         - sort key index, 0 = main table sk (default 0)
  :sort-direction   - :asc or :desc (default :asc)
  :limit            - max number of items to return (must be positive)
  :pagination-token - token from a previous response to fetch the next page

Returns a map with :items (vector) and optionally :pagination-token.
raw docstring

upsertclj

(upsert client
        table-name
        item
        pk
        sk
        &
        {:keys [sks update-time fetch-after-update]
         :or {fetch-after-update false}})

Inserts or updates an item in a DynamoDB table with automatic timestamp management. Sets creationTime on first insert (immutable) and updateTime on every upsert.

Args: client - cognitect AWS client table-name - DynamoDB table name item - map of attributes to set (must not be nil; creationTime/updateTime are managed automatically) pk - partition key value (must not be nil) sk - sort key value (must not be nil)

Options: :sks - secondary keys map: {key {:value val :immutable bool}} immutable keys use if_not_exists (set only on first insert) :update-time - explicit timestamp in ms (defaults to current time) :fetch-after-update - if true, returns the full updated item (default false)

Returns the updated item if fetch-after-update is true, nil otherwise. Returns nil without touching DynamoDB if item has no updatable attributes.

Inserts or updates an item in a DynamoDB table with automatic timestamp management.
Sets creationTime on first insert (immutable) and updateTime on every upsert.

Args:
  client     - cognitect AWS client
  table-name - DynamoDB table name
  item       - map of attributes to set (must not be nil; creationTime/updateTime are managed automatically)
  pk         - partition key value (must not be nil)
  sk         - sort key value (must not be nil)

Options:
  :sks                - secondary keys map: {key {:value val :immutable bool}}
                        immutable keys use if_not_exists (set only on first insert)
  :update-time        - explicit timestamp in ms (defaults to current time)
  :fetch-after-update - if true, returns the full updated item (default false)

Returns the updated item if fetch-after-update is true, nil otherwise.
Returns nil without touching DynamoDB if item has no updatable attributes.
raw 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