ย ยทย I'm a geek ! create applications is a hobby

user doc reference does not work with list view query on "created by"or "owner" user reference typed

Database & APIs

It should be logical and simple... but it does not work ! why ? ๐Ÿ˜ข
As someone ever succeed to use this logic ? Because, I do definitively not.
If I use string type rather than user reference and setting user ID in owner, it works... ๐Ÿ˜ฎ

I've created a cars collection with owner typed user reference.

I've "tagged users" rule on cars collection on the owner field :

for all create, read, write, delete...
and published rules :

I've created a form to add user's cars and an action "create document" in which I've mapped owner field with

Creation is working good and it has set the user reference in owner as expected :

I've finally created a listview query cars collection (without specify any filter as rules expected to filter) = but no items are returned !
and there is a message "rules errors on list view missing insufficient permissions"

If i use a statement data to see during debug what is the user reference used by listviews it contains "xxxx..." which is the user ID and not "/users/xxxx" user reference ! of course it is not accepted by firebase rules... but it should not use user ID but user reference ? ๐Ÿ˜ฎ

Solution which is working (but it's a pitty, isn't it ?): set owner type to string and use "userid" and no more user reference. Filling owner during creation with this userid (so no /users/xxx but xxx).

rules are in this cases the following (! read "owner" in the place of "created_by" as my screen shot is another test but lines was exactly the same except "created_by" name) :

any help would be appreciated. thx.

What have you tried so far?

try different ways with no success except using "string" type and "user ID" rather than user document reference... ๐Ÿ˜ž

Did you check FlutterFlow's Documentation for this topic?
Yes
2
1 reply