Closed amitkalo closed 4 years ago
Ah, just saw this on StackOverflow, but here's what I posted there:
So in a lot of cases geofirestore
minimally modifies the doc you give and then passes it through to Firestore. In this case it looks like Firebase/Firestore is throwing the error, not geofirestore
.
I suspect that the issue is with the reference you're using. If that reference is provided by geofirestore
, it's not necessarily a DocumentReference
that Firestore uses, it is a GeoDocumentReference
. You'll likely want to get the actual DocumentReference
from the native
property:
await geocollection.add({
coordinates: new firebase.firestore.GeoPoint(latlng.lat, latlng.lng),
arrayOfRef: [newRef.native]
});
Let me know if that helps! I'm also making a few assumptions as to your code, so seeing more of what happens before you call the add
method would be awesome.
its not worked since the newRef is not a GeoDocumentReference
as you can see, the newRef is returning from insertNewRef which using firestore-admin to insert new document and return the DocumentReference of it:
await GeoLocationDB.get().then(async function(querySnapshot){ await insertNewRef().then(async function(newRef){ if (querySnapshot.size == 0){ await geocollection.add({ coordinates: new firebase.firestore.GeoPoint(latlng.lat, latlng.lng), posts: [newRef] });
Ok, so I attempted to implement something you're doing in a StackBlitz (I'm using the web client, not the server).
Here's the blitz, and it seems to work just fine. However I noticed an issue with Firestore where if the coordinates are [0, 0] it throws an issue (I'm gonna pass this issue to the Firebase team firebase/firebase-js-sdk#3006)
Great, thanks and i will glad if you will update😊
@MichaelSolati why did you close it? its not resolved yet
Sorry, I didn't hear back from you so I supposed we were good. I'll reopen it now.
@amitkalo did you get to try the code example I wrote?
yes, you can see my answer to your suggest in the older comments here
@amitkalo I'm sorry I dont see any updates you've shared based on my StackBlitz. Could you repost it?
As I say on the comment, it’s not worked and I get the runtime error that newRef dont have property native since its not a ‘ GeoDocumentReference’
What version of geofirestore are you using?
"geofirestore": "^3.4.1"
Can you please provide a GitHub repo or StackBlitz where this issue is reproducible?
hii all im using geofirestore and in my usege i try to add new document to my DB. i do it as mention in the examples with the add functonality and in the data object i want to add an array with pointer to other documents that i insert with firestore.
await geocollection.add({ coordinates: new firebase.firestore.GeoPoint(latlng.lat, latlng.lng), refArray: [newRef] }));
on this line i get the following error: { FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: a custom object (found in field d.refArray)i try to use Object.asset({}, newRef) but its put an empty array. please help