I'm currently trying to build a cloud function to export my Firestore data to my Storage Bucket.
The only example I've found on the Firebase DOCs on how to do this:
https://googleapis.dev/nodejs/firestore/latest/v1.FirestoreAdminClient.html#exportDocuments
EXAMPLE
const firestore = require('@google-cloud/firestore');
const client = new firestore.v1.FirestoreAdminClient({
// optional auth parameters.
});
const formattedName = client.databasePath('[PROJECT]', '[DATABASE]');
client.exportDocuments({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
From that example, it seems that I need to install @google-cloud/firestore
as a dependency to my cloud function.
But I was wondering if I can access these methods using only the firebase-admin
package.
I've thought of that because the firebase-admin
has the @google-cloud/firestore
as a dependency already.
> firebase-admin > package.json
"dependencies": {
"@firebase/database": "^0.4.7",
"@google-cloud/firestore": "^2.0.0", // <---------------------
"@google-cloud/storage": "^3.0.2",
"@types/node": "^8.0.53",
"dicer": "^0.3.0",
"jsonwebtoken": "8.1.0",
"node-forge": "0.7.4"
},
QUESTION:
Is it possible to get an instance of the FirestoreAdminClient
and use the exportDocuments
method using just the firebase-admin
?
Or do I really need to install the @google-cloud/firestore
as a direct dependency and work with it directly?