Document about the "transform" property

This issue has been tracked since 2022-09-13.

Copying from the upcoming release notes:


{
  // ...
  "connections": [
    {
      // ...
      "transform": "${type}[]"
    }
  ]
}

${type} will be replaced by the original type that was generated. In this case, we are transforming it into an array:

// before transformation
const rows = conn.query<{ id: number }>(conn.sql`SELECT id FROM users`)
// after transformation
const rows = conn.query<{ id: number }[]>(conn.sql`SELECT id FROM users`)
                                      ^^

transform accepts the following pattern: string | (string | [(from) string, (to) string])[].

For example:

  • "transform": "${type}[]" (add [] to the end)
  • "transform": ["${type}[]"] (identical to the previous one)
  • "transform": [["Nullable", "Maybe"]] (replaces Nullable with Maybe)
Newbie012 wrote this answer on 2022-09-23
More Details About Repo
Owner Name ts-safeql
Repo Name safeql
Full Name ts-safeql/safeql
Language TypeScript
Created Date 2022-09-08
Updated Date 2023-03-16
Star Count 795
Watcher Count 5
Fork Count 14
Issue Count 7

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date