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

Mapping field. #46

Closed
amcgregor opened this issue Sep 4, 2017 · 1 comment
Closed

Mapping field. #46

amcgregor opened this issue Sep 4, 2017 · 1 comment
Assignees
Labels
2.enhancement New ideas or improvements. area:field Issues relating to Field implementations or their mechanics.
Milestone

Comments

@amcgregor
Copy link
Member

The addition of a Mapping field (a specialization of Array) to allow retrieval and storage of an ordered mapping of objects utilizing a common key field.

Specifically, the following BSON document:

{things: [{name: 'bob', age: 22}, {name: 'alice', potato: true}]}

Would be retrievable:

class Thing(Document):
    class Person(Document):
        name = String()
        age = Integer()
        potato = Boolean()
    
    things = Mapping('.Person')

Thing.find_one().things['bob'].age == 22

Work has already begun on this feature:

  • b7c64ec Added mapping field and update localized to utilize it.
@amcgregor amcgregor added 2.enhancement New ideas or improvements. area:field Issues relating to Field implementations or their mechanics. labels Sep 4, 2017
@amcgregor amcgregor added this to the 1.1.2 Release milestone Sep 4, 2017
@amcgregor amcgregor self-assigned this Sep 4, 2017
amcgregor added a commit that referenced this issue Sep 5, 2017
@amcgregor
Copy link
Member Author

Test coverage complete. As a very explicit note, this is not a special change-tracking mapping; it is recommended to ensure use is either singular, or that you acquire a handle in your local namespace to the attribute's value prior to operating upon it; the mapping is constructed on access so as to preserve the in-database representation within the underlying datastore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.enhancement New ideas or improvements. area:field Issues relating to Field implementations or their mechanics.
Projects
None yet
Development

No branches or pull requests

1 participant