Add cloud firestore data with cloud functions

Means to add data in cloud firestore with cloud functions google
Maybe it will be useful for someone
ex
link get via component web
https://southamerica-east1-project-.cloudfunctions.net/function?uid=DOC&city=Los Angeles
Sem títusdsafdsafdlo

// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access Firestore.
const admin = require('firebase-admin');
admin.initializeApp();
exports.testkodu = functions.https.onRequest(async (req, res) => {
  var docRef = admin.firestore().collection("kodular").doc(req.query.uid);
  let doc = await admin.firestore().runTransaction(t => t.get(docRef))
  if (!doc.exists) {throw ("doc not found");}
  let datos = doc.data()
  if(datos.cities){
    datos.cities.push(req.query.city)
       await doc.ref.update({cities: datos.cities});
       res.json(0);
  }else{
       await doc.ref.update({cities: [req.query.city]});
       res.json(1);
  }

});