收藏
回答

错误代码-502001?

db.collection("booklist").where({
          _id: this.data.bookid,
        }).get().then(res => {
          console.log(res.data[0],"书信息")
          console.log(app.userInfo._id, "用户id")
          db.collection("bookshelf").add({       到加入书架这一步就出错了
            data: {
              userid: app.userInfo._id, //哪个用户执行是添加操作
              _id: res.data[0]._id,
              src: res.data[0].src,
              title: res.data[0].title,
              shortInfo: res.data[0].shortInfo,
              time: new Date(), //本地时间
            }
          }).then(res=>{
              wx.showToast({
                title: '已添加',
                icon: 'success',
                duration: 1500
              })
              this.setData({
                isInList: 1
              });
            
            }).catch(console.error)
到加入书架这一步就出错了,权限什么的都设置了 
回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2020-04-01

    2020-04-01
    有用
    回复 3
    • Sweat.
      Sweat.
      2020-04-01
      res.data[0]._id这是书的_id,上面的是用户的_id
      2020-04-01
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-04-01回复Sweat.
      我写了个demo,还验证了一下
      2020-04-01
      回复
    • Sweat.
      Sweat.
      2020-04-01回复Mr.Zhao
      我知道了 添加进去的时候也会自动生成一个_id和我这个重复了
      2020-04-01
      回复
登录 后发表内容
问题标签