# wixData.filter() Question

**URL:** <https://forum.wixstudio.com/t/wixdata-filter-question/12521>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [February 1, 2019, 1:47pm UTC](https://forum.wixstudio.com/t/wixdata-filter-question/12521 "2019-02-01T13:47:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![athanasios-spachos](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/athanasios-spachos/32/876_2.png) [@athanasios-spachos](https://forum.wixstudio.com/u/athanasios-spachos)\
**Post date:** [February 1, 2019, 1:47pm UTC](https://forum.wixstudio.com/t/wixdata-filter-question/12521/1 "2019-02-01T13:47:38Z")

</div>

I try to filter a dataset to only show content uploaded by some specific people.

Current **user** for example is **“sakisspahos”**.  
There is the " **Friends**" Database, and i want to filter a dataset **“Videos”** (connected to a database “Videos”) by a field " **Uplaoder**" to show only items where " **Uploader**" is one of the users on the " **Friends**" Database.

So based on the example, friends with **sakisspahos** , are " **konstantinapourl**" and " **kostasmpounatso**" so only videos uploaded by them should be shown.

**Friends Database**

 ![](https://us1.discourse-cdn.com/wix/original/3X/7/4/74278306feee8bb363a82145cb649fe880d25f6c.png)

**Videos Database**

![](https://us1.discourse-cdn.com/wix/original/3X/2/f/2f6d3f5cb650e3fbf42d6c81417ec9b2c8e7b2fc.png)

**Code used to filter the repeater**  
**-Items on line 37 are returned correctly.The 2 friends items.**  
**-Line 56 works(the one that uses .not curruser), so the repeater doesn’t show videos uploaded from “sakisspahos”.**  
**-The issue is, that it displays items it shouldnt. By users that are not on the or conditions.**

 ![](https://us1.discourse-cdn.com/wix/original/3X/9/6/96359f0c3eccbe383a3f993bb7ac8d6a0d07aa3c.png)

Code(pasted)

```javascript
function getfriends() {
let curruser = $w("#dataset3").getCurrentItem()._id //Gets the current user, in our example "sakisspahos"(his ID)
let filter = wixData.filter();
wixData.query("Friends")//Queries the "Friends Database" to get all the Users that are friends with "sakisspahos",based on the ID
    .eq("approved", true)
    .eq("user1", curruser)
    .or(
        wixData.query("Friends")
        .eq("approved", true)
        .eq("user2", curruser)
    )
    .find()
    .then((results) => {
 //Here, the items are returned correctly, i checked by console.loging the results.
 //So the results are "konstantinapourl" and "kostasmpounatso" items.
        console.log(results.items)
 if (results.items.length > 0) {
 for (var i = 0; i < results.items.length; i++) { //For each user found do
 if (curruser === results.items[i].user1) { 
 //If the current user is on the user1 field, this means that the user2 field contains the friend ID.                  
                    filter = filter.or(
                        wixData.filter("Videos")
                        .eq("uploader", results.items[i].user2)//an or for the uploader to be the user2(the friend)
                    )
                } else {//If curruser is not the user1, this means he is the user2, so the friend is the user1.
                    filter = filter.or(
                        wixData.filter("Videos")
                        .eq("uploader", results.items[i].user1)//an or for the uploader to be the user1(the friend)
                    )
                }
            }
            filter = filter.not(//filtering not for the uploader to not be sakisspahos(the current user).
                wixData.filter("Videos")
                .eq("uploader", curruser)
            )
            $w("#dataset1").setFilter(filter);
            console.log(filter)
        } else {
 // User has no friends.
        }
    })
}

```
