云功能的 firestore 路径

firestore path for cloud functions

我正在尝试使用 firebase 云功能为我的 flutter 应用程序中的任何新消息发送推送通知,但没有成功。 我编写了代码以将任何新消息数据保存到此路径中的 firestore(messages/groupChatId/groupChatId/DateTime.now().millisecondsSinceEpoch.toString()).

 var ref = FirebaseFirestore.instance
      .collection('messages')
      .doc(groupChatId)
      .collection(groupChatId)
     .doc(DateTime.now().millisecondsSinceEpoch.toString());

之后写了云函数开始指明路径;

exports.sendNotification = functions.firestore.document("messages/groupChatId/groupChatId/DateTime.now().millisecondsSinceEpoch.toString()").onCreate(async(snapshot, context) => {...}

路径中的数据读取方式是否正确?或者我是否必须在路径中的某处使用大括号?有人能告诉我哪里出了问题吗?

所以,我通过像这样更改路径使其工作;

exports.sendNotification = 
functions.firestore.document("messages/{groupChatId}/chats/{chat}").onCreate(async(snapshot, context) => {...}