Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept any function #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KRVJKvothe
Copy link

With the fileWrite, you can send any function in the options.
The function must have the fields path and filecontents.
That's to save the file in anywhere you want like the cloud.
For example:
function saveFileS3 (path, content) {
const params = {
Bucket: s3Bucket,
Key: (new Date()).toISOString() + (!path.startsWith('/') && '/' || '0') + path,
ContentType: 'application/json',
Body: content
}

s3.putObject( params, (err, data) => {
if (err) {
console.log(err)
} else {
console.log('Guardado: ' + path)
}
})
}

To save in an AWS S3 Bucket.
so you send the function in the fileWrite in options, like:

firestore({
accountCredentials: {
project_id: CONFIG.GOOGLE_PROJECT_ID,
private_key: CONFIG.GOOGLE_PRIVATE_KEY,
client_email: CONFIG.GOOGLE_CLIENT_EMAIL
},
backupPath: '',
fileWrite: saveFileS3
}).then(......)

Thank's you for the firestore-backup.

@@ -128,8 +128,11 @@ export class FirestoreBackup {

documentRequestLimit: number;

fileWrite: void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an optional function type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm trying to think of what would be a more apt member name, technically this isn't a fileWrite function anymore, it's an any-way-we-want-to-handle-the-contents function now.

@@ -18,7 +18,8 @@ export type BackupOptions = {|
prettyPrintJSON: boolean,
requestCountLimit: number,
exclude: Array<string>,
excludePatterns: Array<RegExp>
excludePatterns: Array<RegExp>,
fileWrite: void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be an optional function type?

@yoiang
Copy link
Member

yoiang commented Jul 19, 2018

@KRVJKvothe thanks so much for the PR! The idea is great, something that should have been in a long time ago. I've added a few review requests but otherwise it looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants