Hi here there an example for persistance
Hi here there an example for persistance text streaming which has the has the thread and messages schema. Iam finding an issue where i need to pass my threadId to use with useStream() from "@convex-dev/persistent-text-streaming/react".
My goal is to list all message base on my threadId,
Is there a way for me to pass a body?
3 Replies
if you jus want to list all messages by thread id, make use of indexes
in you schema for example
.index("by_stream_updated", ["streamId", "updatedAt"]
and then you can query withIndex like
(replace by_user_updated wth by_stream_updated)
the first field of index is necessary and the 2nd is optional.
.order
arranges based on _creation time, to fetch the latest/updated we add additional field "updatedAt" which will order the results base don updatedAt, 2 birds wth 1 stone.iam curious, isnt streamId should be unique per message? So if that's the case, how are we going to list all messages base on threadId in these case than?
i have a thread & message table in these case
I've figure it out, my approach is to use searchParams instead for my use case to find all message by thread id
mb, i have a custom streaming implementation