1.1.0 • Published 3 years ago
mongodb-selective-export v1.1.0
Mongodb selective export
Export only required documents from the Mongodb.
Prerequisites
- Install mongoexport tool
 - Yaml schema of your db relations
 
Getting started
npx mongodb-selective-export export [options] <JSONentryPoints>
Example:
$ npx mongodb-selective-export export --relations=./relations.yaml --uri="mongodb://localhost:27017/test" '{"collection":"User","query":{"_id":{"$in":[{"$oid":"5a85a984dd5e16cf4ddad6b3"}]}}}'# relations.yaml
User:
  - to: Order
    field: _id # optional, by default _id
    toField: user
Order:
  - to: Product
    field: product
    toField: _id # optional, by default _id
  - to: User # optional, will automatically generate an inverse relation
    field: user
    toField: _id    
Product: []Available commands:
export: export documents from db
Road map
- Test coverage
 - Array in array oid
 - Dynamic relation
 - Parallel export