0
votes

I want to create a trigger function like that:

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);
      }
  });
});

I want to retrieve posts with private value is false documents but It gives an

ReferenceError: isEqualTo is not defined 

What is the correct syntax in NodeJs can anyone help ? Thank you so much.

1

1 Answers

0
votes

For Node.js the syntax is:

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

I highly recommend keeping the Firestore documentation handy, as it has the syntax for most supported platforms (including Node.js) right in there.