yjs/y-websocket

Filter results on request

zzph opened this issue · 1 comments

zzph commented

Hi, firstly thanks for this awesome project Checklist

Is your feature request related to a problem? Please describe. I would like a way to query just a subset of the data from yjs. For simplicity, presume it’s a todo list and we want to filter out “completed “ items.

Describe the solution you'd like Ability to request filtered yjs results (instead of the entire "room"). Query could be passed via the socket eg ws:foo.com/my-room?name=bar, then the filtering itself is done in JS server-side before sending

Describe alternatives you've considered

  • attempted to modify y-socket to decode & filter a result before sending it (such as here).
  • doing 2 requests (first req is a rest responds with indexes of subset items, second req is to yjs and asks for only those indexes).
  • each “item ” is a different room, but seems like a big overhead (performance) If even possible (multiplex)?
  • change data format, using either y.Array or y.Set

Additional context

  • Do not want to 'break' yjs ability 'new' items (eg new Y.Array().push(...))
  • Do not want to 'hear' (eg events/updates) about docs I'm not subscribed to

Huly®: YJS-531

Hi @zzph ,

Something like this is definitely not possible in Yjs for technical reasons (you can't fetch a subset of data). However, you can use subdocuments (see documentation) to achieve the same thing.