def update(_id, *E, **doc): """ Called to update the reaction """ doc.update(*E) doc.update(modified_at=utcnow()) return g.db.reactions.update({"_id" : ObjectId(_id)}, {"$set": doc}, safe=True)
def save(title=None, body=None, article_id=None, author=None, **doc): """ Called to save the reaction. """ doc.update(title=title, body=body, author=author, created_at=utcnow(), article_id=ObjectId(article_id)) _id = g.db.reactions.insert(doc, safe=True) articles.add_reaction(article_id, _id) return _id