【发布时间】: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