How to use the firestore-export-import.initializeApp function in firestore-export-import

To help you get started, we’ve selected a few firestore-export-import examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ffxiv-teamcraft / ffxiv-teamcraft / tools / firestore / db.js View on Github external
const { Firestore } = require('@google-cloud/firestore');
const fs = require('fs');
const Multiprogress = require('multi-progress');
const multi = new Multiprogress(process.stdout);
// In your index.js

const firestoreService = require('firestore-export-import');
const serviceAccount = require('./service-account-beta.json');

// Initiate Firebase App
firestoreService.initializeApp(serviceAccount, 'https://ffxiv-teamcraft-beta.firebaseio.com');

// Start exporting your data

// Create a new client
const firestore = new Firestore();
const backupFile = './lists.json';

const allLists = Object.entries(JSON.parse(fs.readFileSync(backupFile, 'utf8').trim() || '[]')).map(([k, v]) => {
  return {
    ...v,
    $key: k
  };
});

console.log('Lists cache loaded', allLists.length);
github GoogleChromeLabs / sample-pie-shop / src / server / get-data.js View on Github external
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License
 *
 */
const fei = require('firestore-export-import');
import * as admin from 'firebase-admin';
import path from 'path';
import fs from 'fs';

const DEFAULT_CONFIG_FILE = path.resolve(__dirname, '../data/firebase-admin-key.json');
const DATABASE_URL = 'https://pie-shop-app.firebaseio.com';

if (process.env.FB_KEYS) {
  // Try the environment variable first
  fei.initializeApp(require(process.env.FB_KEYS), DATABASE_URL);
} else if (fs.existsSync(DEFAULT_CONFIG_FILE)) {
  // Check the default config file second
  fei.initializeApp(require(DEFAULT_CONFIG_FILE), DATABASE_URL);
} else {
  // Hopefully in Cloud env and can use default credentials
  admin.initializeApp({
    credential: admin.credential.applicationDefault(),
    databaseURL: DATABASE_URL,
  });
  admin.firestore().settings({timestampsInSnapshots: true});
}

let homeData;
let productData;

export function getHomeData() {

firestore-export-import

NPM package for backup and restore Firebase Firestore

MIT
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis