Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

adding document to firebase firestore

Adding new document with auto generated id
//imports
import { db } from "../../config/firebase.config";
import { collection, addDoc } from "firebase/firestore";

//code inside component
const addData = async () => {
	collectionRef = collection(db, "collectionName")
    payload = { whatever your payload is }
    await addDoc(collectionRef, payload)
}
Source by firebase.google.com #
 
PREVIOUS NEXT
Tagged: #adding #document #firebase #firestore
ADD COMMENT
Topic
Name
7+5 =