Как получить $ рядом с работой в Flask-Mongoalchemy

Чтобы добавить к @ssytvane ответ и ответить @Guarav: вы можете добавить «upsert = True», если его не существует:

def update_tags(ref, new_tag):
    coll.update({'ref': ref}, {'$push': {'tags': new_tag}}, upsert = True)

или

def update_tags(ref, new_tag):
    coll.update_one({'ref': ref}, {'$push': {'tags': new_tag}}, upsert = True)
0
задан Creative Joe 15 January 2019 в 22:51
поделиться