M
M
Michael2018-03-26 21:45:18
MongoDB
Michael, 2018-03-26 21:45:18

How to update data in EmbeddedDocument mongoDB?

Hello.
There are three tables

class UserCalendarLayer(mongoengine.EmbeddedDocument):

    i_id = mongoengine.ObjectIdField(default=ObjectId)
    id = mongoengine.StringField()
    summary = mongoengine.StringField()
    time_zone = mongoengine.StringField()
    background_color = mongoengine.StringField()
    foreground_color = mongoengine.StringField()
    access_role = mongoengine.StringField()
    primary = mongoengine.StringField(default="False")
    is_active = mongoengine.StringField(default='True')

class UserCalendar(mongoengine.EmbeddedDocument):

    i_id = mongoengine.ObjectIdField(default=ObjectId)
    provider = mongoengine.StringField()
    name = mongoengine.StringField(default='primary') #"primary"
    access_data = mongoengine.DictField()
    is_active = mongoengine.StringField(default='True')
    email = mongoengine.StringField()
    calendars_layer = mongoengine.ListField(mongoengine.EmbeddedDocumentField(UserCalendarLayer))#, default=UserCalendarLayer))

class User(mongoengine.Document, UserMixin):
    user_id = mongoengine.StringField()
    first_name = mongoengine.StringField()
    last_name = mongoengine.StringField()
    contacts = mongoengine.ListField(mongoengine.EmbeddedDocumentField(UserContact))
    calendars = mongoengine.ListField(mongoengine.EmbeddedDocumentField(UserCalendar))


I need to make a request to update data in the UserCalendarLayer model, I have the i_id of the required entry.
How to query using mongo or mongoenginge?
I'm doing a project on falsk.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question