Basically lets say I have a dataset with seasons (Winter, Spring, Summer, Fall).
If I want to filter the dataset so only the spring options appear I can do so like this:
$w("#dataset1").setFilter( wixData.filter().contains("season", "spring") )
My question would be how do you make it so that it shows the options containing spring and/or fall?
For reference my dataset stores the season options as text like this:
item 1: Fall
Item 2: Summer Winter
Item 3: Spring
Item 4: Summer Fall Spring
(this is not my dataset but an example of which format it is in)
So how would I make it so it shows the options containing Spring and/or Fall?
Hallo Yann Kull,
already took a look into the CORVID-API-REFERENCE ???
Create a query, add an or, and run it
import wixData from 'wix-data';
wixData.query("myCollection")
.lt("age", 25)
.or(
wixData.query("myCollection")
.gt("age", 65)
)
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
let totalCount = results.totalCount;
let pageSize = results.pageSize;
let currentPage = results.currentPage;
let totalPages = results.totalPages;
let hasNext = results.hasNext();
let hasPrev = results.hasPrev();
let length = results.length;
let query = results.query;
} else {
// handle case where no matching items found
}
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
/*
* For example, results contain items where age is:
* 18
* 21
* 67
* 90
*
* But not items where age is:
* 25
* 30
* 40
* 65
*/
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#or
So you have entries like this —> Summer Fall Spring in your data-references?
Use .or + .contains, i think it already will solve your problem.
perhaps something like…
wixData.query("myCollection").contains("season","spring").or( wixData.query("myCollection").contains("season", "summer")).find().then((results)=>{........ and so on ........