I have a collection called GROUPS that points to the PrivateMembersData collection. My page has a dataset that points to the GROUPS collection. I need to filter the dataset based on whether the Owner of the group is the currently logged in member OR whether the user is one of the members belonging to the group crossreferenced by the field “groupMembers”. If I used a query it would look like this:
wixData . query ( "GROUPS" )
. include ( "groupMembers" ) // My crossreference field to PrivateMembersData collection
. eq ( "_owner" , memberId )
. or ( wixData . query ( "GROUPS" )
. include ( "loginEmail" , "mymail@gmail.com" ))
. find ()
. then ( ( results ) => {
console . log ( results );
} );
This works just fine if I use a query, but since I’m using a dataset, I need to filter it in a similar fashion so as to get the same result. Unfortunately, the setFilter function doesn’t allow me to use the “include” statement. How can I do it?
Hi @J.D. and thanks for your reply.
This is what I need to do:
- Website members can create groups. Whoever creates a group becomes the group’s Admin.
- Admins can add other website members as regular non Admin members.
- The groups are displayed with a Repeater object.
- When a user first opens the page, he should see the groups for which he’s Admin as well as all other groups where he’s only a regular non Admin member.
I have my GROUPS collection. When a member creates a group Velo automatically puts his “_id” in the “_owner” field of the collection, so I already know who’s Admin. I now need to get the list of regular members to figure out if one of them is visiting the page. I added to the GROUPS collection a Multi-Reference field called “groupMembers” which points to the PrivateMembersData collection. When a user loads the page, I should filter the dataset connected to the Repeater so it only shows the groups for which the user is Admin or a simple member.
I hope it’s clearer now. Thanks again for your help!