hasSome( )
Refines a query or filter to match items whose specified property value equals any of the specified value
parameters.
Description
The hasSome()
function refines a WixDataQuery
or WixDataFilter
to
only match items where the value of the specified property equals any of
the specified values.
Matching strings with hasSome()
is case sensitive, so "text"
is not equal to "Text"
.
If the value of the specified property is an array, hasSome()
will match
if any of the elements of that array match any of the specified values.
If the specified property contains multiple references, pass item IDs in the
value
property. In such a case, hasSome()
will match if any of the
multiple references match any of the specified ID values.
You can specify a list of values to match by providing an array of
String, Number, or Date types as the value
parameters.
Syntax
function hasSome(propertyName: string, value: string | number | Date | Array<*>): WixDataQuery
hasSome Parameters
NAME
TYPE
DESCRIPTION
The property whose value will be compared with value
.
The values to match against.
Was this helpful?
1let newQuery = query.hasSome("sizes", [30, 38, 42]);
1import wixData from 'wix-data';23// ...45wixData.query("myCollection")6 .hasSome("colors", ["red", "yellow", "blue"])7 .find()8 .then((results) => {9 if(results.items.length > 0) {10 let items = results.items;11 let firstItem = items[0];12 let totalCount = results.totalCount;13 let pageSize = results.pageSize;14 let currentPage = results.currentPage;15 let totalPages = results.totalPages;16 let hasNext = results.hasNext();17 let hasPrev = results.hasPrev();18 let length = results.length;19 let query = results.query;20 } else {21 // handle case where no matching items found22 }23 })24 .catch((error) => {25 let errorMsg = error.message;26 let code = error.code;27 });
1import wixData from 'wix-data';23// ...45wixData.query("myCollection")6 .hasSome("colors", ["red", "yellow", "blue"])7 .gt("age", 25)8 .ascending("last_name", "first_name")9 .limit(10)10 .find()11 .then((results) => {12 if(results.items.length > 0) {13 let items = results.items;14 let firstItem = items[0];15 let totalCount = results.totalCount;16 let pageSize = results.pageSize;17 let currentPage = results.currentPage;18 let totalPages = results.totalPages;19 let hasNext = results.hasNext();20 let hasPrev = results.hasPrev();21 let length = results.length;22 let query = results.query;23 } else {24 // handle case where no matching items found25 }26 })27 .catch((error) => {28 let errorMsg = error.message;29 let code = error.code;30 });
This example gets the items from the movies collection that have a reference in the authors field to an item with an ID that is either 1357 or 2468.
1import wixData from 'wix-data';23// ...45wixData.query("movies")6 .hasSome("actors", ["1357", "2468"])7 .find()8 .then((results) => {9 if(results.items.length > 0) {10 let items = results.items;11 let firstItem = items[0];12 let totalCount = results.totalCount;13 let pageSize = results.pageSize;14 let currentPage = results.currentPage;15 let totalPages = results.totalPages;16 let hasNext = results.hasNext();17 let hasPrev = results.hasPrev();18 let length = results.length;19 let query = results.query;20 } else {21 // handle case where no matching items found22 }23 })24 .catch((error) => {25 let errorMsg = error.message;26 let code = error.code;27 });28