Replace string occurrences in MongoDB fields
- Create a backup of the database for safety in case anything goes wrong
- Create a copy of
.env.example
and name it.env
- Update the variables in
.env
to match your db, target string and replacement string - Follow the format of
in/fields.example.json
to createin/fields.json
- Carefully specify all the fields on which to perform string replacements
The formats below are allowed for the in/fields.json file:
<collection>.<field>
users.email
clients.warehouse
<collection>.<field>.[depth-1-subfield].[depth-2-subfield].[...]
reports.meta.downloads
articles.magazine.editor.name
Overall structure
[
"users.email",
"clients.warehouse",
"reports.meta.downloads",
"articles.magazine.editor.name"
]
Ensure everything on .env
and in/fields.json
is set up properly.
Install dependencies:
- Run:
yarn
ornpm install
Start processing:
- Run:
yarn start
ornpm start