Get and Set Data with Path in RNFIREBASE As we Can do it in Web Firebase #4273
Unanswered
shtaimoortariq
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i have data in deep down collections and sub collections but i couldn't get the data way i got it in web firebase
here is code which i coded in mobile to get 8 level deep collection
refArray.length == 1
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc())
: refArray.length == 2
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc())
: refArray.length == 3
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc(refArray[2])
.collection('files')
.doc(refArray[3])
.collection('files')
.doc())
: refArray.length == 4
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc(refArray[2])
.collection('files')
.doc(refArray[3])
.collection('files')
.doc(refArray[4])
.collection('files')
.doc())
: refArray.length == 5
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc(refArray[2])
.collection('files')
.doc(refArray[3])
.collection('files')
.doc(refArray[4])
.collection('files')
.doc(refArray[5])
.collection('files')
.doc())
: refArray.length == 6
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc(refArray[2])
.collection('files')
.doc(refArray[3])
.collection('files')
.doc(refArray[4])
.collection('files')
.doc(refArray[5])
.collection('files')
.doc(refArray[6])
.collection('files')
.doc())
: refArray.length == 7
? (documentRef = db
.collection('files')
.doc(refArray[0])
.collection('files')
.doc(refArray[1])
.collection('files')
.doc(refArray[2])
.collection('files')
.doc(refArray[3])
.collection('files')
.doc(refArray[4])
.collection('files')
.doc(refArray[5])
.collection('files')
.doc(refArray[6])
.collection('files')
.doc(refArray[7])
.collection('files')
.doc())
: (documentRef = db.collection('files').doc());
and this is my Web Code which can do same but only consume one line with path
const db = App.firestore()
const batch = db.batch()
const upd = ref.split('/')
upd.splice(0, 2)
const result = upd.join('/files/')
console.log(upd, 'AFTER SPLIT AND SPLICE')
let newRef = '/files/'
newRef = newRef.concat(result)
console.log(ref, 'REF ')
console.log(newRef, 'new REF ')
const TimeStamp = firebase.firestore.Timestamp.now()
const geoPoint = new firebase.firestore.GeoPoint(location.latitude, location.longitude)
const flEntity = { ...folderEntity }
const documentReference = db.collection(upd.length > 0 ?
${newRef}/files
: 'files').doc()my newRef variable is /files/doc.id/files/doc.id
which can go deep into how much i wannna make it go deep but i have to do code manually for collection reference where i have to dig down my Dataa would any body please help me regarding This it would be thankfull
Beta Was this translation helpful? Give feedback.
All reactions