Hello, I have a question regarding filtering search, currently, I have a database “orders details” which shows all the details about the order by customers which the ‘data references’ field is by 3 stores that are store A, store B, and store C that is on the database “business name”, and the dynamic page that I created using dataset “business name” contains a dynamic page for store A, store B, and store C. Now, the problem that I face is when I made a search filtering on the dynamic page to shows order details, the order details that be shown are all orders details as store A, store B, and store C. The solution that currently I need to find is how to filter the order details, for example, if the customer buys the products from store A, then the only owner from store A can check that order details based on search filter that he/she search while store B and store C cannot view that order details.
The code that I use on search filter is:-
function uniqueDropDown1 (){
wixData.query( “StorefrontDailyOrder” )
.limit( 1000 )
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w( “#dropdown1” ).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(monthOrder) {
const titlesOnly = monthOrder.map(item => item.monthOrder);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}
export async function dropdown1_click(event, $w) {
$w( “#dataset1” ).setFilter(wixData.filter()
.contains( “monthOrder” , $w( ‘#dropdown1’ ).value))
.then(() => {
console.log( "Dataset is now filtered" );
})
. **catch** ((err) => {
console.log(err);
});
$w( '#repeater1' ).expand();
}
Thanks.