wixData Filter to display owner's items only

Hi there, I have been having issues on how to display only owner’s items as a result after a keypress event to search the database for items posted by the logged-in account owner.
On ready, it displays correctly because I have filtered the dataset to only display site owner items, but when the database is searched, it somehow manages to bypass the filtering.

Below is the code I am using.
Thanks



import wixData from 'wix-data';

let lastfilterTitle
let debounceTimer

function filter (title) {
if (lastfilterTitle !== title) {
let newFilter = wixData.filter();
if (title)
    newFilter =  newFilter.contains('title', title);
        $w('#dataset5').setFilter(newFilter);
        lastfilterTitle = title;
    }
}
export function jobTitle_keyPress(event, $w) {
    if (debounceTimer) {
    clearTimeout(debounceTimer);
    debounceTimer = undefined;
}
    debounceTimer = setTimeout(() => {
        filter($w('#jobTitle').value);
    }, 200);
}

So you have added the filters to your dataset through the Wix Editor itself, like in this page here.
https://support.wix.com/en/article/filtering-database-content-displayed-on-your-page

Read the Wix Dataset API for more info.
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFilter

Setting a dataset’s filter overrides existing filters that were previously set using the setFilter() function or using the Dataset Settings panel in the Editor.

So basically, if you then add another filter on top of your dataset settings, like you have done with your code, then it will override the existing dataset filters and show you everything again.

Great and I was aware of that. I was hoping I could get some Corvid assistance to only display owner Items when searched because it is very important for us that other users do not end up seeing what others are positing from their profiles. It exposes important information to other users.

I have tried several solutions provided by you and other Corvid experts but it seem to only be a solution on a dynamic page and dataset. So it did not work for me.

I appreciate your time and support.

@getintouchishaq When you create a new filter, you need to include the current user’s ID as part of the filter. In this way, you restrict the results of your new filter to the current user’s data.

Hi Yisrael, I am working on same code. Can you tell me what would be WixData Filter Code to match current user id?