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?
2
Answers
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).
You will simply require/import (2) Google Node Client Libraries. It should be rather easy to do. One for interacting w Firestore, the other for interacting w Cloud Storage (bucket).
https://cloud.google.com/nodejs/docs/reference/firestore/latest
and
https://cloud.google.com/nodejs/docs/reference/storage/latest