# MongoDB Partial Export
This tool can be used to dump part of a MongoDB database by following a scheme defined in a yaml file. Let's take a simple version of Github data model. You want to dump all repositories of a given account, and all data recursively associated with every repo.
- collection: accounts
- collection: repos
- collection: commits
## How to
You can use this tool by running the following command :
SOURCE_DB=db1 DEST_DB=db2 go run main.go data/schema.yml
`db1` is the database you want to partially dump, and `db2` is the destination database.
This tools dumps every collection by waiting for its dependency collection to be first dumped. It is then dumped using all object ids of the dependent collection as the foreign key of your collection.
This won't work with all data models, because it assumes data are hierarchical. If you have a user collection it will probably not be exported. You can export it with another schema or by making a full dump.
## Next steps
- Add unit tests