How to increment field in PG

logins: integer('logins').default(1).notNull(),
logins: integer('logins').default(1).notNull(),
await db
.update(users)
.set({ logins: sql`${users.logins} + 1` })
.where(eq(users.id, user.id));
await db
.update(users)
.set({ logins: sql`${users.logins} + 1` })
.where(eq(users.id, user.id));
ERROR: invalid input syntax for type integer: "[object Object]"
CONTEXT: unnamed portal parameter $1 = '...'
STATEMENT: update "User" set "logins" = $1 where "User"."id" = $2
ERROR: invalid input syntax for type integer: "[object Object]"
CONTEXT: unnamed portal parameter $1 = '...'
STATEMENT: update "User" set "logins" = $1 where "User"."id" = $2
This doesn't seem to work for me
2 Replies
Mykhailo
Mykhailo12mo ago
@jakeleventhal what version of drizzle and drizzle-kit are you using?
jakeleventhal
jakeleventhalOP12mo ago
"drizzle-orm": "0.29.2", "drizzle-kit": "0.20.9", seems like this is the same issue as the other thread resolved by not exporting * from drizzle-orm
Want results from more Discord servers?
Add your server