class Comment(db.DynamicDocument): description = db.StringField() post = db.ReferenceField('Post') created_at = db.DateTimeField(required=True, default=datetime.utcnow) user_id = db.ReferenceField(User) # here will store id of the user author = db.StringField(required=True, max_length=50) meta = {'collection': 'comments'}
class Post(db.Document): subject = db.StringField() author = db.StringField(required=True, max_length=50) description = db.StringField() created_at = db.DateTimeField(required=True, default=datetime.utcnow) comments = db.ListField(db.ReferenceField('Comment')) # Post will have a list of comments meta = {'collection': 'posts'}
class Document(db.Document): # name of the file filename = db.StringField() # which assignment this document belongs to assignment = db.ReferenceField('Assignment') # who is submitted the document submitted_by = db.ReferenceField('User') # when submitted the document submitted_date = db.DateTimeField(required=True, default=datetime.utcnow) meta = {'collection': 'documents'}
class Assignment(db.Document): title = db.StringField(required=True, max_length=200) description = db.StringField() # who is created this assignment. that means the reference of the user created_by = db.ReferenceField('User') # which school belongs to this assignment. school = db.ReferenceField('School') # Assignment will have a submission date submission_date = db.DateTimeField(required=True) # Assignment will have a status open or close. true means open false means close status = db.BooleanField(required=True, default=True) # An assignment will have a list of document which we can call documents documents = db.ListField(db.ReferenceField('Document')) meta = {'collection': 'assignments'}
class Chat(db.Document): description = db.StringField(required=True) # A user reference who is added this chat user = db.ReferenceField('User') created_at = db.DateTimeField(required=True, default=datetime.utcnow) meta = {'collection': 'chats'}
class File(db.Document): user = db.ReferenceField('User') filename = db.StringField() tags = db.ListField(db.StringField(), default=list) created_at = db.DateTimeField(required=True, default=datetime.utcnow) meta = {'collection': 'files'}