'''This module defines application data models.'''
from . import db


class Member(db.EmbeddedDocument):
    '''Represents person, participating in this random thing.'''

    name = db.StringField(unique=True, required=True)
    #email = db.StringField(unique=True, required=True)

    def __init__(self, *, name, **kwargs):
        super().__init__(**kwargs)
        self.name = name

    def __repr__(self):
        return '<Member {}>'.format(self.name)


class Room(db.Document):
    '''Represents group of members to choose from.'''

    meta = {'collection': 'rooms'}

    name = db.StringField(unique=True, required=True)
    members = db.SortedListField(db.EmbeddedDocumentField(Member), ordering='name')

    def __init__(self, *, name, members, **kwargs):
        super().__init__(**kwargs)
        self.name = name
        self.members = members

    def __repr__(self):
        return '<Room {}>'.format(self.name)

@@ -544,16 +544,25 @@
 meta = %7B
+%0A        
 'collect
@@ -574,16 +574,156 @@
  'rooms'
+,%0A        'indexes': %5B%0A            %7B%0A                'fields': %5B'members.name'%5D,%0A                'unique': True%0A            %7D%0A        %5D%0A    
 %7D%0A%0A    n
@@ -789,27 +789,8 @@
 s = 
-db.SortedListField(
 db.E
@@ -804,16 +804,20 @@
 Document
+List
 Field(Me
@@ -825,26 +825,8 @@
 ber)
-, ordering='name')
 %0A%0A  

Add db index