ordering when using an index vs. without an index
useQuery
will return undefined
until it gets the first response, but shouldn't return it after that. I'm guessing you're talking about db.query...collect()
returning undefined
? If you see it again, holler!5 Replies
I was talking about the
db.query...collect()
, and I'm actually able to reproduce it if I revert my schema indexes back to what I had yesterday. Give me a moment and I'll share more details
I was mistaken; looks like it's an ordering issue:
steps1
result
steps2
result:
Now is that actually incorrect behavior? 😛
Does
If not specified, the order defaults to ascending.in https://docs.convex.dev/api/interfaces/server.Query#order mean that if an ordering is not specified with
order()
, the order will be ascending? Or that you can call order()
without arguments to have the result be ordered ascending?That will be fixed soon. Without an index, we have a default ordering of _creationTime. If you use an index, we used to still have a default ordering of
_id
so your steps1 result is ordered by _id and the latter is ordered by _creationTime
@presley changed this recently. We're glad the change is making it less confusing 🙂Is that what
Results will be returned in index order.in https://docs.convex.dev/api/interfaces/server.QueryInitializer#withindex meant/means?
Right. I'm going to be fixing up those docs to reference the new _creationTime default ordering. Very open to feedback on it
Got it, great! Yes, as it stands it's confusing, but the change you say is coming is exactly what I would have assumed, based on the docs as they're written now (excepting what's in
withIndex
)