项目作者: keito5656

项目描述 :
An automatic tool for copying and converting Firebase Authentication data to BigQuery.
高级语言: TypeScript
项目地址: git://github.com/keito5656/firebase-authentication-to-bigquery-export.git
创建时间: 2019-06-17T15:34:54Z
项目社区:https://github.com/keito5656/firebase-authentication-to-bigquery-export

开源协议:MIT License

下载


Firebase Authentication to BigQuery export

An automatic tool for copying and converting Firebase Authentication data to BigQuery.
Inspired by firestore-to-bigquery-export

  • Create a BigQuery dataset with tables corresponding to your Firebase Authentication.
  • This package doesn’t write anything to Firebase Authentication.

Installation

npm i firebase-authentication-to-bigquery-export

  1. import bigExport from 'firebase-authentication-to-bigquery-export'
  2. // or
  3. const bigExport = require('firebase-authentication-to-bigquery-export')
  4. // then
  5. const GCPSA = require('./Your-Service-Account-File.json')
  6. bigExport.setBigQueryConfig(GCPSA)
  7. bigExport.setFirebaseConfig(GCPSA)

How to

API

  1. bigExport.setBigQueryConfig(
  2. serviceAccountFile // JSON
  3. )
  1. bigExport.setFirebaseConfig(
  2. serviceAccountFile // JSON
  3. )
  1. bigExport.createBigQueryTables()
  1. bigExport.copyToBigQuery(
  2. verbose // Boolean
  3. )
  1. bigExport.deleteBigQueryTables()

Examples

  1. /*
  2. Initialize BigQuery dataset named 'authentication' with four firebase authentication.
  3. */
  4. bigExport.createBigQueryTables()
  5. .then(res => {
  6. console.log(res)
  7. })
  8. .catch(error => console.error(error))

Then, you can transport your data:

  1. /*
  2. Copying and converting from Firebase Authentication data
  3. */
  4. bigExport.copyToBigQuery()
  5. .then(res => {
  6. console.log('Copied ' + res + ' documents to BigQuery.')
  7. })
  8. .catch(error => console.error(error))

After that, you may want to refresh your data. For the time being, the quick and dirty way is to delete your tables and make new ones:

  1. // Deleting the given BigQuery tables.
  2. bigExport.deleteBigQueryTables()
  3. .then(res => {
  4. console.log(res)
  5. })
  6. .catch(error => console.error(error))

Maybe you want to refresh / overwrite a single table?

  1. // Overwrites the users BigQuery table with fresh data from Firebase Authentication
  2. bigExport.deleteBigQueryTables()
  3. .then(() => {
  4. bigExport.createBigQueryTables()
  5. })
  6. .then(promises => {
  7. return bigExport.copyToBigQuery()
  8. })
  9. .then(res => {
  10. console.log('Copied to BigQuery.')
  11. })
  12. .catch(error => console.error(error))

Issues

Please use the issue tracker.