Help Debugging
Would someone be able to help me debug this error:
Here is my query:
And then calling it from the frontend
10 Replies
The error message says "must provide arg 2 to search" so I'd try console.log-ing
args.term
on the previous line to see what it is, since that's what you're passing as the second argument to search()
.
Also double-check that npm run dev
or npx convex dev
or however you keep convex functions updating is runningOkay sounds good. I tried console logging args last night and saw the term which is what made me confused.
I’ll try again fresh this morning and give ‘er another go.
Does removing the
.eq('parentPostId', undefined)
give the same error (or replacing it with something other than undefined
)? If not, this sounds like a bug on our endSo I console logged args in the query and I get this:
Which is what I expect
And when I remove the .eq() call the error stops being thrown.
If I pass an empty string to the eq() call instead of undefined the error also does not get thrown.
Oh yeah that's it, it's that undefined!
.eq('parentPostId', undefined)
Sorry, the error message should be about eq
, not searchI'm for now just going with a filter() call after the withSearchIndex call and that seems to be working, but I think if I could do that filtering within the search it might be more performant.
Is undefined as an argument not supported within that method?
I don't think this syntax allows searching for something to be equal to
undefined
, what is it you're trying to do here?
you're looking for results where that field doesn't exist? parentPostId
is optional these records?Yeah exactly basically I have posts that can also potentially be replies to other posts based on whether they have a parent or not.
When I'm searching I just want to consider posts that are truly just parents only.
And I was going based off this statement on this page of the docs:
https://docs.convex.dev/text-search#equality-expressions
Which does seem to work in other filter expressions okay.
Cool, I'll look into this — the library code validates that that argument is not undefined, it could be that this isn't supported or it could be we're just validating too strictly.
Oh no worries at all. I really appreciate you guys being so willing to help me especially on a Saturday morning. I think I'm all square now for what I need to accomplish. 🙏