Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Delete path and its recursive child path in firebase cloud function

Posted on November 14, 2022

Solution 1 :

I decided to take a look at this sample on github and noticed a few things:

I had all the packages except firebase-tools, which is weird because I’ve wrote in command line 70 times npm install -g firebase-tools as the document indicates. So I decided to add it by myself so now package.json contains the firebase-tools dependency

"firebase-admin": "^9.1.1",
"firebase-functions": "^3.11.0",
"firebase-tools": "^8.9.0"

Then I rewrote the require of firebase_tools in index.js:

const firebase_tools = require('firebase-tools')

And just in case I set the token that you get by executing the command line: firebase login:ci

Set here firebase functions:config:set fb.token="SET_TOKEN_HERE"

Now execute the next command line: firebase deploy –only functions to update.

And finally works 🙂

Problem :

I want to delete a document and all the collections that is inside the document from firestore. For that I’m using cloud function with node 8 as engine and it’s actually deployed. But something isn’t working as expected.

this is my route
/ postsCollection / user / user_posts_collection / large documents

So I want to delete the user document and all the things that contain inside that document => user_posts_collection and its documents

Node.js, Cloud Function

exports.deleteUserPostsDocument = functions
    .runWith({
        timeoutSeconds: 540,
        memory: '2GB'
    })
    .https.onCall(async(data, context) => {

        const path = data.path;

        await firebase_tools.firestore
            .delete(path, {
                project: process.env.GCLOUD_PROJECT,
                recursive: true,
                yes: true,
                token: functions.config().fb.token
            });

        return {
            path: path
        };
    });

Kotlin, call to function

val path = "/posts/user"
val data = hashMapOf("path" to path)

var success = false

functions
    .getHttpsCallable("deleteUserPostsDocument")
    .call(data)
    .continueWith {task ->
        success = task.isSuccessful
    }.await()

return success

The code is exactly the same as they show here, I just removed the code to access if you are just only admin. So there shouldn’t be any problem with that.

READ  [ANSWERED] java - app keeps stopping, but cannot find any problems
Powered by Inline Related Posts

I followed all the steps they indicated, with firebase login, firebase login:cli etc.. and I can see the function being deployed into my firebase cloud functions

Question: What am I missing?

Edit 1: Here’s a screenshot that it’s calling to the cloud function, but doesn’t delete anything.
enter image description here

Comments

Comment posted by cloud.google.com/functions/docs/…

Note that env.GCLOUD_PROJECT is deprecated, use env.GCP_PROJECT instead.

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress