Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let Schema be initialized with a Collection instance #14

Open
allonhadaya opened this issue Dec 10, 2015 · 1 comment
Open

Let Schema be initialized with a Collection instance #14

allonhadaya opened this issue Dec 10, 2015 · 1 comment
Assignees

Comments

@allonhadaya
Copy link

First off, what a sweet piece of code... Thanks for making it!

I have a suggestion which might simplify your code tremendously without taking away any of its expressiveness: Let schema be initialized by an instance of Collection (the thing that get_mongo_cursor currently returns).

Using the library would be a whole hell of a lot easier because its clients could use the full range of MongoClient initialization options. Also, collections could be specified flexibly.

Examples:

def every_schema(client):
    for database in client.database_names():
        db = client[database]
        for collection in db.collection_names():
            yield (database, collection, Schema(db[collection], limit=100).get_schema())

list(every_schema(MongoClient( ... )))

Or:

client = MongoClient( ... )
Schema(client.mydatabase.mycollection).print_schema()

Anyway, thanks for making this awesome code. I like how direct the implementation is!

I'd be happy to work on this proposal if you like the idea, or have any feedback.

@utsavtiwary04
Copy link
Collaborator

@allonhadaya Thanks a lot ! The proposal does sound useful and would definitely make the library more flexible for the user. Please go ahead and work on it if you feel like - we can update the library and ship it as a part of the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants