Skip to content

Releases: DWTechs/Antity-pgsql.js

Single `consumer` object

11 Apr 20:25

Choose a tag to compare

  • Replace separate consumerId / consumerName parameters with a single consumer object ({ id?, nickname? }) across all relevant APIs:
    • query.update(), query.insert(), query.upsert(), query.archive() now accept consumer?: { id?: number | string, nickname?: string } instead of two separate arguments
    • Express middlewares (add, update, upsert, archive, sync) now read res.locals.consumer.id and res.locals.consumer.nickname instead of res.locals.consumerId / res.locals.consumerName

Fix 'in' 'notin'

29 Mar 11:33

Choose a tag to compare

  • Fix notIn match mode not working in filter SQL generation:
  • Add "in" and "notIn" to allowed match modes for numberand string

Fix filters empty values

28 Mar 21:05

Choose a tag to compare

  • Fix filter handling to exclude empty values from WHERE clauses:
    • Filters with empty string values are now skipped
    • Filters with empty arrays are now skipped
    • Filters with null values are skipped except for is and isNot match modes

Sync

28 Mar 17:37

Choose a tag to compare

  • Add bulk sync functionality:
    • New sync() Express middleware atomically synchronises a table with the full provided row list inside a single PostgreSQL transaction (BEGIN / COMMIT / ROLLBACK on failure)
    • Incoming rows without an ID (or with an unknown ID) are inserted; rows with a known ID are updated; existing rows absent from the list are deleted
    • Accepts optional idField in request body (defaults to 'id') to specify the identity column
    • Accepts optional filters in request body to scope the managed set — rows outside the filter are never touched
    • Returns synced rows with generated IDs in res.locals.rows
    • Returns operation summary { inserted, updated, deleted } in res.locals.sync
    • Supports consumerId / consumerName forwarding for history tracking on inserts and updates
  • Add syncArraySubstack getter returning [normalizeArray, validateArray, sync] middleware chain

UPSERT

24 Mar 20:39

Choose a tag to compare

  • Add UPSERT functionality using PostgreSQL's INSERT ... ON CONFLICT ... DO UPDATE syntax:
    • New query.upsert() method generates upsert queries with configurable conflict targets
    • Supports single or multiple column conflict targets (e.g., 'id' or ['email', 'username'])
    • Properties with both INSERT and UPDATE operations are automatically included in upsert
    • Optionally includes consumerId and consumerName for history tracking
    • Supports RETURNING clause to retrieve updated/inserted row IDs
  • Add upsert() Express middleware for handling upsert operations:
    • Expects rows and conflictTarget in request body
    • Returns upserted rows with IDs in res.locals.rows
    • Supports chunking for bulk operations
  • Add convenience Express substack middlewares:
    • upsertArraySubstack: Returns [normalizeArray, validateArray, upsert] middleware chain
    • upsertOneSubstack: Returns [normalizeOne, validateOne, upsert] middleware chain

Add dedicated `Archive` query

19 Mar 19:50

Choose a tag to compare

  • Add dedicated Archive query :
    • Replaces the previous approach of passing archived: true through the generic Update query
    • Generates a simplified UPDATE ... SET archived = true WHERE id IN (...) query directly
    • Optionally appends consumerId and consumerName as single scalar values (not per-row CASE blocks)
  • Add query.archive() method to SQLEntity using the new Archive class
  • Add properties getter to SQLEntity returning the list of Property instances passed at construction

`update` middleware forwards rows to `res.locals.rows`

16 Mar 19:45

Choose a tag to compare

  • update middleware now forwards sanitized and normalized rows to res.locals.rows for use in subsequent middlewares and response handling. Like add and get middlewares

Fix wildcard placement in LIKE queries

15 Mar 14:06

Choose a tag to compare

  • Fix wildcard placement in LIKE queries:
    • Wildcards (%) are now added to string values instead of SQL parameter placeholders
    • Affects matchModes: startsWith, endsWith, contains, notContains
    • SQL now generates LIKE $1 with value '%abc%' instead of LIKE %$1% with value 'abc'

Array based filters

15 Mar 09:56

Choose a tag to compare

  • Add support for array-based filter format with multiple filters per property:
    • Filters now accept both simple format (single object) and complex format (array of objects)
    • Simple format: {name: {value: "John", matchMode: "contains"}} (backward compatible)
    • Complex format: {name: [{value: "John", matchMode: "contains", operator: "or"}]} (new)
    • Support logical operators (AND/OR) to combine multiple filters on the same property
    • Example: {name: [{value: "John", operator: "or"}, {value: "Jane", operator: "or"}]}
  • Fix isFilterable property in declaration file

isFilterable and other new property names

14 Mar 20:41

Choose a tag to compare

  • Rename Property interface properties for better clarity and consistency:
    • typeCheckisTypeChecked: Boolean flag to enable/disable type checking
    • filterisFilterable: Boolean flag to enable/disable filtering in SELECT operations
    • needrequiredFor: Array of REST methods (POST, PUT, PATCH) that require this property
    • sendisPrivate: Boolean flag inverted - send: true becomes isPrivate: false
  • Rename entity getter method:
    • unsafePropsprivateProps: Returns array of property names that are private
  • Update dependencies:
    • "@dwtechs/antity": "0.16.0"