Issue
I want to convert all my document ID's to an array so I can do perform array.includes() query.
this is my code -
this.db.collection('camps', ref => ref.where('id', '==', "fxvb95"))
.snapshotChanges().subscribe(data => {
data.forEach(doc => {
const y = doc.payload.doc.data()['altUID'];
console.log(y)
});
this is result in log
exampleUID1
exampleUID2
How do i change these into single value or an array?
Solution
Something like this might work:
this.db
.collection("camps", (ref) => ref.where("id", "==", "fxvb95"))
.snapshotChanges()
.subscribe((data) => {
const myArray = [];
data.forEach((doc) => {
const y = doc.payload.doc.data()["altUID"];
console.log(y);
myArray.push(y);
});
console.log(myArray);
});
Answered By - eko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.