Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Should I do GeoFirestore transactions in Cloud Functions or Client-side?

I am using this library https://geofirestore.com/ to create a document in a collection if no other document already exists within the given coordinates. Now, should I use this library's method for transactions in the Cloud function or directly in the app?

I personally don't see a reason to do it in the Cloud, tho I might be wrong so I am asking for your opinion.

const geocollection = GeoFirestore.collection('chats');
const query = geocollection.limit(1).near({ center: new firebase.firestore.GeoPoint(latitude, longitude), radius: 0.03 });

GeoFirestore.runTransaction((transaction) => {
  const geotransaction = new GeoTransaction(transaction);
  return geotransaction.get(query).then((sfDoc) => {
    if (sfDoc.exists) {
      sfDoc.docs.forEach(documentSnapshot => {
        if (documentSnapshot.exists) {
          firestore().collection('chats')
            .doc(documentSnapshot.id)
            .get()
            .then((res) => {                  
                // insert new document
                geocollection.add({
                  name: 'Geofirestore',
                  uid: device_id,                     
                  coordinates: new firebase.firestore.GeoPoint(latitude, longitude),
                  created: currenttime
                })                  
            })
        }
      });
    } else {
      geocollection.add({
        name: 'Geofirestore',
        uid: device_id,           
        coordinates: new firebase.firestore.GeoPoint(latitude, longitude),
        created: currenttime
      })
    }
  });
});
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

If you want the location of the document to be unique in its collection, consider using that location as the basis for the document ID, or some value derived from the location (such as a hash, or the geohash that Geofirestore uses).

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!