I'm trying to query a collection for an exact combination of values in an object in a document.
The 'array-contains' operator returns all the documents those properties appear across the collection when I'm looking to know if the exact combination exist or not in a document.
EXAMPLE: In a 'styles' collection, each document has an array that includes a unique color combination of styles. I want to query to see if the exact combination of colors already exists in the collection in one of the documents.
Collection of 'styles':
{
"style1" : [ { "color" : [ "blue", "red"] } ],
"style2" : [ { "color" : [ "blue", "red", "green" ] } ],
"style3" : [ { "color" : [ "blue", "red", "yellow", "grey" ] } ],
"style4" : [ { "color" : [ "red", "green" , "yellow" ] } ]
}
let checkStyleExist = this.afs.collection("styles", ref => ref
.where("color", "array-contains", ["blue", "red"]))
.ref.get()
checkStyleExist.docs.map(res => console.log(res))
RESULT: I get a list of documents where blue and red appear. How do I query a collection for a document with the EXACT values in an object? The ["blue", "red"] does not work to query for an exact match.