btw the dashboard custom query is always
btw the dashboard custom query is always highlighting the keyvalue on this as invalid
return await ctx.db.query("table").withIndex('field', (q) => q.eq('field', { keyValue: 'stringValue'})).take(1);
11 Replies
Thanks for the report, what does your schema look like for
field?
Scrolling over the highlight should give you an error message, let me know if it's unexpectedv.optional(v.record(v.string(), union(v.ids))),
Type 'string' is not assignable to type Id<""> | Id<> etc
what is
union(v.ids)?v.union(
v.id('table1'),
v.id('table2'),
etc
Is "stringValue" (from the original query) a valid id?
Yeah i tried it with and without a valid id
cool afaik this should work. I'll let @ari take it from here
the query does give a result, its just showing a syntax error that is not real
Was able to reproduce! I also reproduced it inside of a real query in my own project, so it's not just the dashboard, but a bug in our type system. We'll look into getting this fixed
nice, yeah i had something similar in ts but not as a query, still trying to figure out what changes i'm going to make 🙃 . I was testing assumptions in the dashboard first.
this is a expected use case right? .withIndex('field', (q) => q.gt('field', { keyValue: undefined})).take(10); to get records with keytype but any value, i just wish i could do that with .eq
with that current error i cant exactly tell if this will pass ts. as the my ids union is non-optional
i would do
.gte("field", { keyValue: null as any })
I don't think the undefined will work as a value in an object
Also this doesn't mean "records with keytype but any value". It means "recods that sort after { keyValue: null } in the sort order where objects are ordered as tuples of (key, value) where keys are sorted. In this ordering {cat: 1, dog: 2} < {dog: null} < {dog: 1}