EN VI

Node.js - Is there a new FirestoreAdminClient to use now when cloud functions are recommended to run on 2nd gen?

2024-03-12 05:00:07
Node.js - Is there a new FirestoreAdminClient to use now when cloud functions are recommended to run on 2nd gen?

When doing data export from Firestore to a bucket I am following the suggested solution on: Schedule data exports.

Some cherry-picked code from the solution is as follows:

const client = new firestore.v1.FirestoreAdminClient();
...
const projectId = process.env.GCP_PROJECT;
const databaseName = client.databasePath(projectId, '(default)');

return client.exportDocuments({
    name: databaseName,
    outputUriPrefix: bucket,
    collectionIds: []
    })
...

Now, with 2nd gen I know that e.g. project Id instead can be picked up using a pre-defined parameters from firebase-functions/params

But is there a new FirestoreAdminClient that should/could be used to do databasePath() and exportDocuments() with?

Solution:

No. The version you're seeing for FirestoreAdminClient (from the node module "@google-cloud/firestore") has nothing to do with the version of Cloud Functions (from the node module "firebase-functions") supported by the Firebase CLI. They are almost entirely unrelated to each other, except by how you choose to use them in the same project.

FirebaseAdminClient from @google-cloud/firestore has its own documentation on GCP which you can read and understand on its own terms and use anywhere that runs nodejs (including Cloud Functions).

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login