【问题标题】:Flutter Firebase Cloud Functions NodeJs where clause reference error isEqualtoFlutter Firebase Cloud Functions NodeJs where子句引用错误isEqualto
【发布时间】:2021-05-15 21:36:30
【问题描述】:

我想创建一个这样的触发器函数:

exports.onCreateFollowers = functions.firestore
  .document("/userFollowers/{followerId}/followers/{userId}")
  .onCreate( async (snapshot, context) => {
  console.log("Follower Created",snapshot.id);
  const userId = context.params.userId;
  const followerId = context.params.followerId;


  const followerUserPostsRef = admin.firestore()
  .collection('posts')
  .doc(followerId)
  .collection('userPosts')
  .where('private', isEqualTo, false); // This line gives an error


  const timelinePostsRef = admin.firestore()
  .collection('timelineFollowers')
  .doc(userId)
  .collection('timelinePosts');


  const querySnapshot = await followerUserPostsRef.get();


  querySnapshot.forEach(doc => {
      if(doc.exists){
          const postId = doc.id;
          const postData = doc.data();
          timelinePostsRef.doc(postId).set(postData);
      }
  });
});

我想检索具有私有值的帖子是虚假文档,但它给出了一个

ReferenceError: isEqualTo is not defined 

NodeJs 中的正确语法是什么?谁能帮忙?非常感谢。

【问题讨论】:

    标签: node.js firebase google-cloud-firestore


    【解决方案1】:

    对于 Node.js,语法是:

      .where('private', "==", false);
    

    我强烈建议将 Firestore documentation 放在手边,因为它包含大多数受支持平台(包括 Node.js)的语法。

    【讨论】:

      猜你喜欢
      • 2018-06-11
      • 2017-10-05
      • 2018-06-17
      • 2020-09-18
      • 2019-02-04
      • 2018-10-02
      • 2018-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多