List Filters Array Contains ? #2213
-
Hey, is there a filter that i can search value in a List like "array-contains" in Firestore. Mostly i am looking for "array-not-contains" which even Firestore does not support. I looked little bit but this "ColumnSerializable" do not have that much function to filter. Example:
If there is no such method making this filter is it make sense to make all id's as a String and searching in ? String likerIDList = 'id1,id2,id3'; Thanks for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If the list is a relation field you are able to do that with the See: https://docs.serverpod.dev/concepts/database/filter#any Post.db.find(
session,
where: (table) => table.likerIDList.any((o) => o.id.equals(myId)),
); However, if you have stored the list as a json blob then currently there is no built-in support to query for specific items within the json blob. But you can always write a custom query using the For your use case the query could look something like this: But if you use |
Beta Was this translation helpful? Give feedback.
If the list is a relation field you are able to do that with the
any
method.See: https://docs.serverpod.dev/concepts/database/filter#any
and how to setup a relation: https://docs.serverpod.dev/concepts/database/relations/one-to-many
However, if you have stored the list as a json blob then currently there is no built-in support to query for specific items within the json blob.
But you can always write a custom query using the
unsafeQuery
method.https://docs.serverpod.dev/concepts/database/raw-access
For your use case the query could look something like this:
https://stackoverflow.com/…