项目作者: emmansun

项目描述 :
golang extract mongodb schema tool
高级语言: Go
项目地址: git://github.com/emmansun/extract-mgo-schema.git
创建时间: 2018-05-08T03:28:51Z
项目社区:https://github.com/emmansun/extract-mgo-schema

开源协议:

下载


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