Hi.
I have a “VOTES” collection with fields - questionId (text) and roomNo (number), also there some more fields but it is not important here.
Here is a function:
export function removeVotesFor(pQuestionId, pRoomNo) {
console.log(“-> Searching votes [ Q=” + pQuestionId + “, R=” + pRoomNo + " ]…");
wixData.query("VOTES")
.contains("questionId", pQuestionId)
.and( wixData.query("VOTES").contains("roomNo", pRoomNo) )
.find()
.then( (results) => {
onVotesFound(results);
} )
. **catch** ( (error) => {
let errorMsg = error.message;
let code = error.code;
console.log("!Votes.Qry.ERR# " + code + “, msg:” + errorMsg);
} );
}
I need to query collection by 2 fields - questionId and roomNo .
I searched this forum and tried to do it in 2 ways I found here:
1)
wixData.query(“VOTES”)
.contains(“questionId”, pQuestionId)
.contains(“roomNo”, pRoomNo)
.find().then( … )
- wixData.query(“VOTES”)
.contains(“questionId”, pQuestionId)
.and( wixData.query(“VOTES”).contains(“roomNo”, pRoomNo) )
.find().then( … )
Both variants does not work!
I can clearly see that collection contains lot of records with specified qusetionId and roomNo.
How to query collection by 2 (or more fields) then?
Also I seen strange error message:
!Votes.Qry.ERR# WD_VALIDATION_ERROR, msg:Failed to perform query on [VOTES].
Invalid .contains parameter value [Number]. .contains parameter must be a String.
I tried to pRoomNo.toString() instead of pRoomNo but nothing changed - it was still not able to find appropriate records.
What are rules to match fields datatypes? Why I seen such error message if roomNo is numeric and search parameter also numeric?