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