这是我的数据结构。
{
"books" : [ {
"bookID" : 0,
"Title" : "Romance",
"author" : "alan smith",
"PublishDate" : "2017-05-23",
"bookText" : "Some article text here...",
"Category" : "aventure"
},
{
"bookID" : 1,
"Title" : "love",
"authr" : "Alice maldove",
"PublishDate" : "2017-05-22",
"bookText" : "Some article text here...",
"Category" : "World"
}
],
"UserActions" : [
{
"UID" : "3049873049870987x87098",
"book" : 0,
"Read" : true,
"Liked" : true,
"Saved" : false
},
{
"UID" : "3049873049870987x87098",
"ArticleID" : 2,
"Read" : true,
"Liked" : false,
"Saved" : false
}
]
}
这就是我找书的方式
this.booksCollection = this.afs.collection('books');
this.books = this.booksCollection.snapshotChanges().pipe(
map(actions => actions.map(a =>{
const data = a.payload.doc.data() as Test;
const id = a.payload.doc.id;
return { id, ...data };
})))
在我的html页面中,我不知道如何根据登录的用户将书籍设置为已读或喜欢。