I have this type of data model:
And I would like to query for: industry, solution, and country.
These are all enums:
Now from my code, I would like to query for these in a 3 and condition:
This is the data-model api explorer link: https://cdn.builder.io/api/v2/content/barion-userstory-data?apiKey=32f148657e2646be8562eb4e6ebfa190&limit=1
This is how I try fo fetch from my code:
const queryArray = []
if(solution){
queryArray.push({
solution: {
$elemMatch: solution.key
}
} )
}
if(industry){
queryArray.push({
industry: {
$eq: industry.key
}
} )
}
if(country){
queryArray.push({
country: {
$eq: country.key
}
} )
}
console.log(queryArray)
const result=await builder.getAll('barion-userstory-data', {
options: {
noTargeting: true,
query: {
$and: queryArray
},
},
limit: 9999999,
omit: 'data.blocks',
})
console.log(result)
How my queryArray looks like:
What I try to achieve is, retrieve the data which are:
- The data’s country property equals the country type
- The data’s industry property equals the industry type
- The data’s solution list property contains the solution type
Example query:
(https://cdn.builder.io/api/v1/query/32f148657e2646be8562eb4e6ebfa190/barion-userstory-data:62235058?omit=data.blocks&apiKey=32f148657e2646be8562eb4e6ebfa190&noTargeting=true&query.$and.0.solution.$elemMatch.type=sol1&query.$and.1.industry.$eq.type=type3&query.$and.2.country.$eq.type=country2")
Hope you can help me, because it always returns empty list which is not good enough.