Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emmansun/extract-mgo-schema
golang extract mongodb schema tool
https://github.com/emmansun/extract-mgo-schema
extract-mongodb-schema golang mongodb
Last synced: 3 days ago
JSON representation
golang extract mongodb schema tool
- Host: GitHub
- URL: https://github.com/emmansun/extract-mgo-schema
- Owner: emmansun
- Created: 2018-05-08T03:28:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-18T05:19:49.000Z (over 6 years ago)
- Last Synced: 2024-06-20T16:49:43.096Z (5 months ago)
- Topics: extract-mongodb-schema, golang, mongodb
- Language: Go
- Size: 2.06 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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)`
1. For slice []interface{}, also handle at most 100 records.
1. Handle bson.D as embedded document.Depends on
1. [https://github.com/globalsign/mgo](https://github.com/globalsign/mgo "golang mongodb driver")
2. [https://gopkg.in/urfave/cli.v1](https://gopkg.in/urfave/cli.v1 "command line go application")**Sample command**: extract_mgo.exe -database mongodb://db_owner:db_owner@localhost:47017/sampledb -format csv -output mongo_schema.csv