I cant append new integers in a integer array

          platforms: sql`ARRAY_CAT(${cryptoToken.platforms}, ARRAY['${coin.platform.id}'])`,


i have tried 1000000 ways
but i want to append it if possible?!

here is the schema:

export const cryptoToken = pgTable("crypto_token", {
  id: integer("id").primaryKey(),
  rank: integer("rank"),
  name: text("name").notNull(),
  symbol: text("symbol").notNull(),
  slug: text("slug").notNull(),
  is_active: integer("is_active").notNull(),
  first_historical_data: text("first_historical_data"),
  last_historical_data: text("last_historical_data"),
  platforms: integer("platforms")
    .array()
    .notNull()
    .default(sql`ARRAY[]::integer[]`),
});


i just want to append integers to the array when available,




this errors:
const insertResult = await db
        .insert(cryptoToken)
        .values({
          name: coin.name,
          symbol: coin.symbol,
          slug: coin.slug,
          is_active: 1,
          first_historical_data: coin.first_historical_data,
          last_historical_data: coin.last_historical_data,
          id: coin.id,
          platforms: sql`ARRAY_CAT(${cryptoToken.platforms}, ARRAY['${coin.platform.id}'])`,
          rank: coin.rank,
        })
        .onConflictDoUpdate({
          target: cryptoToken.id,
          set: {
            name: coin.name,
            symbol: coin.symbol,
            slug: coin.slug,
            is_active: 1,
            first_historical_data: coin.first_historical_data,
            last_historical_data: coin.last_historical_data,
            platforms: sql`ARRAY_CAT(${cryptoToken.platforms}, ARRAY['${coin.platform.id}'])`,
            rank: coin.rank,
          },
        });
Was this page helpful?