Import & Export

Exporting Collections in Fuego

Fuego provides a powerful export feature that allows users to extract Firestore collections in various formats, tailoring the output to their specific needs. This guide explains how to use the export functionality effectively.

Accessing the Export Feature

  1. Navigate to the desired Firestore collection.
  2. Click on the Tools menu and select Export Collection.
  3. A dialog box will appear, presenting various export configuration options.

Export documents from firestore

Export Formats

Fuego supports multiple export formats:

1. CSV (Comma-Separated Values)

  • Ideal for spreadsheet applications and structured data analysis.
  • Options include:
    • Include document paths: Export the full Firestore document path.
    • Include metadata: Adds creation, modification, and read timestamps.
    • Include all attributes: Ensures all fields are included.
    • Sort fields alphabetically: Organizes fields in a predictable order.
    • Export objects as: Choose between flattening nested structures or keeping them as structured JSON.
    • CSV delimiter: Select the delimiter (comma, semicolon, etc.).

2. JSON Formats

Fuego offers various JSON export options:

  • JSONL (JSON per line): Recommended for programmatic processing and structured data storage.
  • JSON (as map): Exports data as a JSON object where each document is a key-value pair.
  • JSON (as array): Outputs the collection as an array of JSON objects.

Options for JSON exports include:

  • Include document paths: Adds Firestore document paths.
  • Include metadata: Includes timestamps for record tracking.
  • Include all attributes: Ensures complete data extraction.
  • Data format customization:
    • Timestamp format: Defines the format for date/time fields.
    • Geopoint format: Defines how latitude/longitude data is structured.
    • Firestore reference format: Defines how Firestore document references are stored.
  • Attribute selection: Allows exporting only specific fields. Turning Include all attributes off seeds the list from the collection schema; the export cannot start while the list is empty, so remove the fields you do not want rather than clearing it.

3. YAML

  • A human-readable format often used for configuration files and structured data representation.

Filtering Data

  • The export tool includes an option to Export only documents that meet the criteria, enabling users to filter data before extraction.

Transform Script

Enable Transform each document with a custom script to reshape every document with JavaScript before it is written to the file. The script runs inside the app, once per exported document, and receives:

  • doc — the document, with a DocumentSnapshot-like surface (doc.id, doc.data(), doc.get('a.b'), doc.ref, timestamps as Date)
  • data — the row the export options produce: masked when anonymization is on, and limited to the picked fields when Include all attributes is off (doc always carries the whole document, so you can still read a field you chose not to export)
  • the common globals — db, database(), fetch, util, the object helpers get / pick / omit, … — described in the Custom Scripts reference

Return the object to write to the file, or undefined to omit the document from the export:

// Join a related document into each exported row
const owner = await db.collection('users').where('uid', '==', data.ownerId).limit(1).get();
return {
  id: doc.id,
  title: data.title,
  ownerEmail: owner.empty ? null : owner.docs[0].data().email,
};

The script runs last, after every other option has shaped the row, and what it returns is what gets written — a field it adds is not filtered out by the attribute selection. The returned object still goes through the export format options above: the timestamp, geopoint and Firestore reference formats you selected apply to the values it contains.

NOTE

When anonymization is enabled, masking runs before the script: data already contains the masked values, and the script never sees the real data. The Test button in the script editor respects this too — test runs mask the data and apply the attribute selection before the script executes, so the preview matches the exported file.

The If the script fails on a document setting decides whether a failing document is skipped (the default — failures are listed in the job details) or stops the export. Scripts can be saved to the library and reloaded with Load script… — see Custom Scripts for the full contract and limits.

Saving Preferences

Users can Save Preferences to streamline future exports with the same settings.

Confirmation

Once all settings are configured, click Confirm to start the export process.


This guide covers the essential aspects of exporting Firestore collections using Fuego. Whether you need structured CSV output, JSON variants for programmatic use, or YAML for configuration files, Fuego provides flexible options to meet your needs.