Gallery with images from multiple rows

I have a database ‘portfolio’ with one column ‘project-type’ and a column ‘gallery’ .

The ‘project-type’ fields contain one or multiple tags. The ‘gallery’ fields contain media galleries.

Now there are new pages where the client wants to display alle media from all galleries of a specific tag.
So the gallery from each row that also contains the tag ‘restoration’ in the project-type field.

I will have to display these images together in one gallery at a specific page.

Please help me to start this. Reference to API’s needed (as opposed to a complete answer) are also very much appreciated.

Thanks,

Solution below.

import wixData from ‘wix-data’ ;
let allImages = [];
let project_tag = “value_of_tag_to_filter”;

$w . onReady ( function () {

wixData . query ( “Portfolio_DB” )
. contains ( “project_type” , project_tag )
. ascending ( “title” )
. find ()
. then ( ( results ) => {
if ( results . items . length > 0 ) {
let projecten = results . items ;
for ( var i = 0 ; i < projecten . length ; i ++) {
for ( var j = 0 ; j < projecten [ i ]. gallery . length ; j ++) {
allImages . push ( projecten [ i ]. gallery [ j ]);
}
}
$w ( “#MyGallery” ). items = allImages ;
} else {
// handle case where no matching items found
$w ( “#MyGallery” ). hide ();
}
} )
. catch ( ( error ) => {
let errorMsg = error . message ;
let code = error . code ;
} );

});