xantiagoma / drizzle-cursor

Drizzle ORM - Utils to generate cursor pagination

Home Page:https://www.npmjs.com/package/drizzle-cursor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not work with date columns

erickreutz opened this issue · comments

const cursorConfig: CursorConfig = {
  cursors: [{ order: 'DESC', key: 'createdAt', schema: schema.users.createdAt }],
  primaryCursor: { order: 'DESC', key: 'id', schema: schema.users.id },
};

const cursor = generateCursor(cursorConfig);

When then passing it to db.queries.users.findMany results in:

value.toISOString is not a function. (In 'value.toISOString()', 'value.toISOString' is undefined)

Got the same issue

Hi @erickreutz @croshim do you have a reproducible example? I added some tests and SQL generated query works fine, I guess could be due to null record that drizzle's eq, gt or lt functions not handle.

Hi,

I was able to find a workaround for this error by changing the schema definition from:

createdAt: timestamp('created_at').notNull().defaultNow(),

to

createdAt: timestamp('created_at', { mode: 'string' }).notNull().defaultNow(),

yes,same problem. this fixed.

 createdAt: customTimestamp('createdAt', {
      withTimezone: true,
      precision: 3,
    })
      .notNull().default(sql`now()`),

I want my date column to be nullable

Experiencing the same error. Tried with both drizzle v0.29.5 and v0.30.10. Same "value.toISOString" message.