Angularfire2:如何使用useractions设置用户对帐簿记录执行的操作

时间:2018-07-30 17:26:20

标签: angularfire2 angular6

这是我的数据结构。

   {
       "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页面中,我不知道如何根据登录的用户将书籍设置为已读或喜欢。

0 个答案:

没有答案