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.