MCPcopy Create free account
hub / github.com/liveblocks/liveblocks / findMany

Method findMany

packages/liveblocks-react/src/ThreadDB.ts:186–202  ·  view source on GitHub ↗

* Returns all threads matching a given roomId and query. If roomId is not * specified, it will return all threads matching the query, across all * rooms. * * Returns the results in the requested order. Please note: * 'asc' means by createdAt ASC * 'desc' means by updatedAt DES

(
    // TODO: Implement caching here
    roomId: string | undefined,
    query: ThreadsQuery<TM> | undefined,
    direction: "asc" | "desc",
    subscriptions?: Record<SubscriptionKey, SubscriptionData>
  )

Source from the content-addressed store, hash-verified

184 * Subscriptions are needed to filter threads based on the user's subscriptions.
185 */
186 public findMany(
187 // TODO: Implement caching here
188 roomId: string | undefined,
189 query: ThreadsQuery<TM> | undefined,
190 direction: "asc" | "desc",
191 subscriptions?: Record<SubscriptionKey, SubscriptionData>
192 ): ThreadData<TM, CM>[] {
193 const index = direction === "desc" ? this.#desc : this.#asc;
194 const crit: ((thread: ThreadData<TM, CM>) => boolean)[] = [];
195 if (roomId !== undefined) {
196 crit.push((t) => t.roomId === roomId);
197 }
198 if (query !== undefined) {
199 crit.push(makeThreadsFilter(query, subscriptions));
200 }
201 return Array.from(index.filter((t) => crit.every((pred) => pred(t))));
202 }
203}

Callers 7

CommentPluginProviderFunction · 0.45
$onStateReadFunction · 0.45
constructorMethod · 0.45
ThreadDB.test.tsFile · 0.45
onCreateFunction · 0.45

Calls 5

makeThreadsFilterFunction · 0.90
everyMethod · 0.80
pushMethod · 0.45
fromMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected