[英]How to write data to a subcollection of Firestore in v9 react JS
db.collection("rooms").doc(channelId).collection("messages").add({
message: input,
timestamp: serverTimestamp(),
user: 'Apollos',
userImage: 'https://naniwallpaper.com/files/wallpapers/eren-yeager/1-EREN%20YEAGER-1080x1920.jpg'
});
这应该如何在 firestore v9 中出现?
import { doc } from "firebase/firestore";
const messageRef = doc(db, "rooms", chanelID, "messages");
const update = {
message: input,
timestamp: serverTimestamp(),
user: 'Apollos',
userImage: 'https://naniwallpaper.com/files/wallpapers/eren-yeager/1-EREN%20YEAGER-1080x1920.jpg'
}
setDoc(messageRef, update, { merge: true });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.