Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

firestore add document

import { doc, setDoc } from "firebase/firestore"; 

// Add a new document in collection "cities"
await setDoc(doc(db, "cities", "LA"), {
  name: "Los Angeles",
  state: "CA",
  country: "USA"
});
Comment

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)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: process env react undefined 
Javascript :: js select div 
Javascript :: app.use 
Javascript :: js math.trunc 
Javascript :: javascript break for loop 
Javascript :: nodejs mysql getting the id of an inserted row 
Javascript :: Get LocalStorage from WebView react native 
Javascript :: boolean object js 
Javascript :: javascript pass parameter to event listener 
Javascript :: how to make form in javascript 
Javascript :: question mark and colon in javascript 
Javascript :: ignore eslint warning one line 
Javascript :: how to loop an object in javascript 
Javascript :: ajax upload image 
Javascript :: open bootstrap modal with javascript 
Javascript :: jquery set hidden field value 
Javascript :: factorial javascript function 
Javascript :: javascript if browser out of focus 
Javascript :: get promise result from json() javascript 
Javascript :: not in array js 
Javascript :: viewmodelprovider example 
Javascript :: worker timeout 
Javascript :: javascript test if string starts with alphabet 
Javascript :: sequelize relation does not exist 
Javascript :: nodejs user input 
Javascript :: how to change package name in ios react native 
Javascript :: firebase where or 
Javascript :: sequelize order with include 
Javascript :: check if an array contains a string in javascript 
Javascript :: save canvas as image from website 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =