Run a check
- Open a collection and run the query whose documents you want to check (with no filter, that's the whole collection).
- Choose Actions ▾ → Check data….
- Tick what to look for:
- Duplicate values in a field you choose, such as
email: documents that share the same value. It's an exact match: "Ada" and "ada" are different. - References to missing documents in one reference field, or in every reference field: references that point at documents that don't exist, such as an order whose customer was deleted.
- Fields with more than one type: a field that's a number in most documents and text in a few, including fields inside maps.
- Duplicate values in a field you choose, such as
- Choose how many documents to check: 1,000, 10,000, 100,000 or every matching document. Firetool counts them first and says what the check will read; a reference check also reads each referenced document once. Checking more than 10,000 asks first.
- Choose Run check. It runs as a task, so Tasks shows how far it is, and you can pause or cancel it.
Each document read is a Firestore read, billed like any other. Nothing is written.
Read the results
The dialog lists what it found, in plain words: for duplicates, each shared value and the documents that have it; for references, each missing document and the documents that point at it; for types, each field with how many documents hold each type. Click a document to open it. References to another project or database are counted but not looked up.
Save the report
Save report (JSON) keeps everything the check found. Save problems (CSV) writes one line per finding (the check, the field, the value or type, how many documents, and the documents), for a spreadsheet.
Run it in CI
Use in CI… shows the firetool command that runs the same check, for example:
firetool check my-project customers --duplicates email --references '*' --types --limit 10000
It prints what it found and ends with exit code 6 when it finds problems (0 when it doesn't), so a CI step fails. --json prints the report; --where narrows the documents like a query. In CI, give it a key for the run with --key-file.
Questions
Does Check data change my documents?
No. It only reads: the documents the query matches and, for the reference check, each referenced document once. Fixing what it finds is up to you, for example with Set a value in documents or by editing the documents it lists.
How is this different from the Schema tab?
The Schema tab compares documents with an expected schema you saved: fields of another type, missing required fields and fields not expected. Check data needs no saved schema and also finds duplicate values and references to missing documents.
Does it need Pro?
Checking reads data, which works in the Free edition. Fixing what it finds (changing documents) needs Pro.
Related
- Schema: the fields of a collection, and checking documents against an expected schema.
- The firetool command:
checkand the other commands, for scripts and CI. - Bulk field changes: fix a field across many documents.