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

Support for TypedFrame class #12

Open
njordr opened this issue Dec 9, 2016 · 2 comments
Open

Support for TypedFrame class #12

njordr opened this issue Dec 9, 2016 · 2 comments

Comments

@njordr
Copy link

njordr commented Dec 9, 2016

Hi.
It would be great if MongoFrame implements also a check of field type/structure.

Let me say I want to have all the documents of a certain type with the same _id structure:

class Test(Frame):
    _db = 'testdb'
    _collection = 'testcollection'
    _fields = {
        '_id': {
            'template': 'test_id_'
            'type': str
        },

so when I create a new Test class, i could do the following:

Test(_id=1234).insert()

and the result _id will be "test_id_1234"

In this way it's more simple also to document the structure of the document.

Let me know if this could be in the philosophy of MongoFrames or it's better to use an external validator. In the latter case, any advice?

Thanks

@anthonyjb anthonyjb changed the title check on field structure Support for TypedFrame class Dec 11, 2016
@anthonyjb
Copy link
Member

anthonyjb commented Dec 11, 2016

Hi @njordr,

We have been looking at adding support for a TypedFrame class that would allow simple type validation for documents based on Python types. I've avoided this in general because of the performance overhead but I see no reason not to add it as something people can use optionally.

My personal preference when working with Mongo is to keep validation logic separate (for example within forms) but this isn't to everyones taste and I'm not convinced by any means I'm correct anyhow.

I'm working on a web development framework based on flask, MongoFrames (and a bunch of other open source libraries we're intending to release shortly) which is dividing my time (and that of my colleagues) across a wide array of tasks currently. I expect this to be the case until March when we hope to officially release the new web development framework, included in that planned work are a number of updates to MongoFrames including support for a TypedFrame class - but as of now I don't have a more accurate time frame than that I'm afraid.

@njordr
Copy link
Author

njordr commented Dec 11, 2016

Thank you for your reply. I'll wait to see your web framework :)

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

No branches or pull requests

2 participants