I want to filter out the only content which is book marked by user, the structure of the data is shared below
this.contentList = afs.collection < Content > ('Content', ref => ref.where('isActive', '==', true) .where("BookmarkedBy.UserID", "==", "hvC2WQL5JJG3Hbq1hxJe") ) .snapshotChanges().map(actions => { return actions.map(a => { const data = a.payload.doc.data() as Content; data.$key = a.payload.doc.id; return { ...data }; }); });
I think i'm making mistake here
.where("BookmarkedBy.UserID","==" , "hvC2WQL5JJG3Hbq1hxJe")
Is there any way I can apply filter on array items inside a collection? any help in this regards will be highly appreciated.
{
title: "My great post",
categories: [
"technology",
"opinion",
"cats"
]
}
With the data structure above, there is no way to perform this query.
Consider this alternative data structure, where each category is the key in a map and all values are true:
{
title: "My great post",
categories: {
"technology": true,
"opinion": true,
"cats": true
}
}
Reference Link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.