Query Signals
Query signals in TeamPlay represent the result of a query on a collection. They are created using the sub() function or useSub() hook with query parameters.
Creating a Query Signal
Properties and Methods
ids
A signal containing an array of IDs for the documents in the query result.
extra
A signal containing extra query metadata returned by the server, such as count metadata.
getIds()
Returns an array of ids for the query results.
The result is always a string[]. Non-string ids are filtered out.
getExtra()
Returns extra query metadata.
For query signals, this is equivalent to $activeUsers.extra.get(). For aggregation signals, getExtra() returns the aggregation rows, the same value as .get().
map(callback)
Maps over the documents in the query result.
reduce(callback, initialValue)
Reduces the documents in the query result to a single value.
find(predicate)
Finds the first document in the query result that satisfies the predicate.
Iteration
Query signals are iterable, allowing you to use them in for...of loops:
Notes
- Query signals are reactive. Changes to the underlying data or to the query result will automatically update components using the query signal.
- The documents within a query signal are themselves signals, allowing for nested reactivity.
- For public documents in query results, configured identity fields are available in
get()results and match the document id.idFieldsdefaults to['_id']. idsandextraare reserved metadata properties on query signals. Use the collection path, such as$.users['ids'], when you need a document whose id has one of those names.