Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i update my firebase v8 code to v9 in React-native?

So i want to set my documents on firebase in a way such that a submitted email becomes the document ID
With v8 of Firebase i can do

db.collectiion('dbName')
.doc({authorizedUserEmail})
.set({
'myProperty: dataType'
})

But with v9 i cannot figure it out even while using the doc
https://firebase.google.com/docs/firestore/query-data/get-data

Also i’m writing React-native

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As explained in the doc, you can do as follows:

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

await setDoc(doc(db, "dbName", {authorizedUserEmail}), {
  'myProperty: dataType'
});

Note that "collection" takes only one "i" (your code contains db.collectiion('dbName')).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading