#Convex ID's accepted in string index equality comparators

2 messages · Page 1 of 1 (latest)

quartz river
#

This makes sense I guess since the ID is indeed a string, but this is becoming a regular "gotcha" as I'm walking through some internal migrations.

    const legacyItem = await db
      .query('items')
      .withIndex('byExternalId', (q) => q.eq('externalId', itemId))
      .unique()

In this example, itemId is a convex ID. The externalId field expects a string - I would love some sort of option to cause this to be a type error.

dire arch
#

Feedback noted, although this is kind of hard since IDs are a subset of strings. There’s not a good type for “strings that aren’t valid convex IDs” but perhaps there are some typescript tricks we could use here