The script library
The one-off cleanup script you wrote last quarter is rarely one-off. The script library is where those live.
Saving a script
From the JavaScript editor, choose Save to library. A saved script has:
- A name — what it does, in a few words
- A description — the longer version, for the version of you that has forgotten
- Tags — for grouping, such as
migration,audit,cleanup
Open the library with Cmd/Ctrl+Shift+S.
Running against any database
A saved script is not bound to the project it was written in. Open it, point it at a different project or database, and run. The projectId and databaseId globals tell the script where it is, if it needs to care:
async function run() {
console.log(`Running against ${projectId} / ${databaseId}`);
// …
}
This is how a verification script written against staging gets reused, unchanged, against production.
Sharing
Scripts can be exported to a file or shared as a link. When someone opens a script they did not write, FireFetch shows a review banner first — the script is displayed but not run until they have read it and chosen to.
Read shared scripts before running them, exactly as you would a shell script someone sent you. FireFetch makes the review step deliberate, but it cannot make the judgement for you.
Ideas worth saving
- A schema audit that reports documents missing a required field
- A verification pass that runs before and after a migration
- An export of a specific slice of data you are asked for regularly
- A fixture generator for seeding a development database
Something unclear or out of date? Email[email protected].