OINO TS
    Preparing search index...

    Class OINONoSqlAwsDynamo

    AWS DynamoDB implementation of OINONoSql.

    Authenticates using static IAM credentials supplied as a JSON-encoded connection string. Connection parameters map as:

    • params.url → optional custom endpoint URL (e.g. for DynamoDB Local: http://localhost:8000)
    • params.table → DynamoDB table name
    • params.connectionStr → JSON string: {"region":"…","accessKeyId":"…","secretAccessKey":"…"}
    • params.staticPartitionKey → scope all operations to a fixed partition key

    Register and use via the factory:

    import { OINONoSqlFactory } from "@oino-ts/nosql"
    import { OINONoSqlAwsDynamoDB } from "@oino-ts/nosql-aws"

    OINONoSqlFactory.registerNoSql("OINONoSqlAwsDynamoDB", OINONoSqlAwsDynamoDB)

    const nosql = await OINONoSqlFactory.createNoSql({
    type: "OINONoSqlAwsDynamoDB",
    url: "",
    table: "myTable",
    connectionStr: JSON.stringify({
    region: "us-east-1",
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
    })
    })
    const api = await OINONoSqlFactory.createApi(nosql, {
    apiName: "entities",
    tableName: "myTable"
    })

    The target table must have:

    • A HASH key of type String (any attribute name is accepted)
    • A RANGE key of type String (any attribute name is accepted)

    The actual attribute names are read from the table during validate() and stored on the instance. The OINO API field names (partitionKey, rowKey) will reflect the real DynamoDB attribute names once the backend is validated.

    Two additional system attributes are managed automatically:

    • _timestamp – ISO-8601 timestamp, set on every upsert
    • _etag – UUID v4, regenerated on every upsert

    All custom entity data is stored as top-level item attributes and serialised into OINONoSqlEntry.properties on read.

    Set staticPartitionKey to scope all operations to a fixed partition key, allowing multiple logical tables to share one physical DynamoDB table:

    const nosql = await OINONoSqlFactory.createNoSql({
    type: "OINONoSqlAwsDynamoDB",
    url: "",
    table: "sharedTable",
    connectionStr: process.env.DYNAMO_CONNECTION_STR,
    staticPartitionKey: "myLogicalTable"
    })

    Filters on partitionKey are used to choose between Query (cheap, when an equality predicate on partitionKey is detected) and Scan (full-table).

    All predicates except like are translated to DynamoDB FilterExpression (evaluated server-side, but billed at scan cost). like predicates are evaluated in-memory after the DynamoDB response is received.

    DynamoDB operators supported: =, <>, <, <=, >, >=, attribute_exists, attribute_not_exists, AND, OR, NOT.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    isConnected: boolean = false
    isValidated: boolean = false
    name: string

    Table name

    supportsAutoKey: boolean = false

    Whether this backend can auto-generate primary key values when none are supplied in a POST request. Defaults to false; override in subclasses that support server-side key generation (e.g. UUID on insert).

    Methods

    • Coerce a single data value into a form that can safely be passed to the datasource as a bind parameter (as opposed to printCellAsValue, which formats it as an inline SQL literal).

      The default implementation returns the value unchanged. SQL datasources override this to apply driver-specific coercions (e.g. converting Date/boolean for drivers that only accept primitive bind types). Non-SQL datasources (blob, nosql) can ignore it.

      Parameters

      • cellValue: OINODataCell

        data value to bind

      • nativeType: string

        native type name for the table column

      Returns OINODataCell

    • Attach a static OINONoSqlDataModel to the given API, adding the five standard fields that mirror the OINONoSqlEntry structure.

      Field mapping to DynamoDB item attributes:

      OINO field DynamoDB attribute Key role
      _hashKeyAttr discovered HASH attr Partition key
      _rangeKeyAttr discovered RANGE attr Sort key
      timestamp _timestamp Managed, string
      etag _etag Managed, string
      properties (all other attrs) JSON-serialised

      Parameters

      • api: OINOApi

        the OINONoSqlApi whose data model is to be initialised

      Returns Promise<void>

    • List entities from the table.

      Uses Query when an equality predicate on partitionKey can be extracted from the filter (or when staticPartitionKey is set); otherwise falls back to Scan.

      All predicates except like are translated to a DynamoDB FilterExpression and evaluated server-side. like predicates are evaluated in-memory after the response is received.

      Parameters

      Returns Promise<OINONoSqlEntry[]>

    • Print a single data value from serialization using the context of the native data type with the correct SQL escaping.

      Parameters

      • cellValue: OINODataCell

        data from sql results

      • nativeType: string

        native type name for table column

      Returns string

    • Upsert (insert or replace) an entity.

      _timestamp is set to the current UTC time on every upsert. _etag is set to a new UUID v4 on every upsert.

      All fields in entry.properties are written as top-level DynamoDB item attributes alongside the key and system fields.

      Parameters

      Returns Promise<void>

    • Walk the OINOQueryFilter tree and attempt to build a DynamoDB FilterExpression string, accumulating placeholder names and values into builder.

      Returns undefined for sub-trees that contain untranslatable predicates (currently only the like operator). For OR nodes, if either child cannot be expressed, the entire OR returns undefined because omitting one branch would change the semantics.

      Parameters

      • filter: OINOQueryFilter

        filter node to translate

      • builder: ExprBuilder

        mutable accumulator for placeholder names / values

      Returns string