How to use firestore-export-import - 8 common examples

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() {
github GoogleChromeLabs / sample-pie-shop / tools / import_products.js View on Github external
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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.

import initializeApp from '../services/firebase';
const fei = require('firestore-export-import');

initializeApp();
fei.restore('../src/data/products.json');
github GoogleChromeLabs / sample-pie-shop / tools / import_home.js View on Github external
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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.

import initializeApp from '../services/firebase';
const fei = require('firestore-export-import');

initializeApp();
fei.restore('../src/data/home.json');
github ffxiv-teamcraft / ffxiv-teamcraft / tools / firestore / db.js View on Github external
async function fetchLists() {
  const data = await firestoreService
    .backup('lists');
  fs.writeFileSync(backupFile, JSON.stringify(data.lists));
}
github GoogleChromeLabs / sample-pie-shop / src / server / get-data.js View on Github external
export function getProduct(productUrl) {
  if (productData) {
    return findUrl(productData, productUrl);
  } else {
    fei.backup('products').then((data) => {
      productData = data.products.data.items;
      return findUrl(productData, productUrl);
    });
  }
}
github GoogleChromeLabs / sample-pie-shop / src / server / get-data.js View on Github external
export function getHomeData() {
  if (homeData) {
    return homeData;
  } else {
    fei.backup('home').then((data) => {
      homeData = {
        categories: data.home.categories.data,
        products: data.home.products.data,
      };
      return homeData;
    });
  }
}
github GoogleChromeLabs / sample-pie-shop / src / server / get-data.js View on Github external
export function getProducts(category) {
  if (productData) {
    return filterCategory(productData, category);
  } else {
    fei.backup('products').then((data) => {
      productData = data.products.data.items;
      return filterCategory(productData, category);
    });
  }
}

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