@earth-app/collegedb
    Preparing search index...

    Function buildUpdate

    • Builds an UPDATE statement from a column to value object and a WHERE map.

      The WHERE map is required; an empty condition throws rather than emit an unfiltered UPDATE that would rewrite every row. null in the values map sets a column to SQL NULL; null in the where map matches with IS NULL.

      Parameters

      • table: string

        Target table name

      • values: ColumnValues

        Column to value map of changes to apply (at least one)

      • where: ColumnValues

        Column to value equality conditions (at least one)

      • options: { returning?: string | boolean | string[] } = {}

        Update modifiers (RETURNING)

      Returns BuiltQuery

      The parameterized SQL and its bindings (SET bindings first, then WHERE)

      If no changes or no WHERE conditions are provided

      const { sql, bindings } = buildUpdate('users', { name: 'Ada' }, { id: 'u1' });
      // sql: UPDATE "users" SET "name" = ? WHERE "id" = ?
      // bindings: ['Ada', 'u1']