How to filter where array field contains a value?
inArray() operator works the opposite way (checking if a value is in a literal array).I could use
fn.where(), but this wont work on on-demand data, as far as I understand.Use case:
Data Structure
Database: 3 tables with many-to-many relationship
API Response: I am using query collections.
The Problem
Goal: Filter articles where
tags array contains a specific tag ID.Current approach (what I'm doing now):
Issue: Articles collection is on-demand.
fn.where() runs client-side after fetching ALL data, defeating the purpose. Need expression-based operator compiled to backend query.Potential Solutions
Option 1: Should there be an
arrayContains()/arrayIncludes() operator?Option 2: Use junction table with joins instead of embedded array?
TanStack DB mimics tabular data, maybe the solution is to work with the actual junction table instead of the embedded array?
Option 3: Something else, maybe I am missing something...