Skip to content

emmansun/extract-mgo-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

This is a golang tool to extract mongodb schema. The main steps are:

  1. List all collections from mongdodb database
  2. Handle collection one by one
    1. Select 100 documents and analysis document's fields type according object real type. Using []bson.D as result type: var results []bson.D err := c.Find(bson.M{}).Limit(MaxTryRecords).Sort("-_id").All(&results)
    2. For slice []interface{}, also handle at most 100 records.
    3. Handle bson.D as embedded document.

Depends on

  1. https://github.com/globalsign/mgo
  2. https://gopkg.in/urfave/cli.v1

Sample command: extract_mgo.exe -database mongodb://db_owner:db_owner@localhost:47017/sampledb -format csv -output mongo_schema.csv

About

golang extract mongodb schema tool

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages