Coder Social home page Coder Social logo

attiqlab / firestore-migrator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codediodeio/firestore-migrator

0.0 2.0 0.0 126 KB

:bullettrain_side: A CLI utility for moving data to and from Cloud Firestore

Home Page: https://angularfirebase.com/lessons/import-csv-json-or-excel-to-firestore/

TypeScript 100.00%

firestore-migrator's Introduction

Fire Migrate

๐Ÿ‘€ Firestore now has an official import/export process. Consider that your first option if it suits your needs. If it does not, continue reading...

CLI tool for moving data in-n-out of Cloud Firestore.

  • Import/Export CSV, Excel, or JSON files to/from Firestore.
  • Encode/Decode Firestore data types such as GeoPoint, Reference, Timestamp, etc.

Watch the screencast

Install

  • Clone and run npm install
  • Download the service account from your Firebase project settings, then save it as credentials.json in the project root.
  • npm run build and you're off and running.

Import Data to Firestore

  • Push your local data to the Firestore database.
  • Selectively import [collections...] from source file to Firestore.
  • Omitting [collections...], or specifying root "/" will import all collections.
import|i [options] <file> [collections...]

Options:

-i, --id [field]            Field to use for Document IDs. (default: doc_id)
-a, --auto-id [str]         Document ID token specifying auto generated Document ID. (default: Auto-ID)
-m, --merge                 Merge Firestore documents. Default is Replace.
-k, --chunk [size]          Split upload into batches. Max 500 by Firestore constraints. (default: 500)
-p, --coll-prefix [prefix]  (Sub-)Collection prefix. (default: collection)
                            
-s, --sheet [#]             Single mode XLSX Sheet # to import.
                            
-T, --truncate              Delete all documents from target collections before import.
                            
-d, --dry-run               Perform a dry run, without committing data. Implies --verbose.
-v, --verbose               Output document insert paths
-h, --help                  output usage information

Examples:

fire-migrate import --dry-run test.json myCollection
fire-migrate import --merge test.INDEX.csv myCollection
fire-migrate i -m --id docid test.xlsx myCollection

Export Data from Firestore

  • Pull data from Firestore to a JSON, CSV or XLSX file.
  • Selectively export [collections...], or entire database with root "/".
  • Exports Sub-Collections by default, optionally disabled.
  • Splits CSV/XLSX collections into separate files/sheets with an INDEX.
export|e [options] <file> [collections...]

Options:


-n, --no-subcolls           Do not export sub-collections.
-p, --coll-prefix [prefix]  Collection prefix (default: collection)
-i, --id-field [id]         Field name to use for document IDs (default: doc_id)

-v, --verbose               Output traversed document paths
-h, --help                  output usage information

Examples:

fire-migrate export --verbose --no-subcolls myCollectionRootLevel.json myCollection
fire-migrate export users-posts.json users posts
fire-migrate e -v firestore-dump.xlsx

firestore-migrator's People

Contributors

stildalf avatar codediodeio avatar fergusmeiklejohn avatar

Watchers

James Cloos avatar Fred van Rijswijk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.