Beispiel #1
0
 def delete(self, person_id):
     try:
         # Added the [0] place since the objects function returns an array of the objects
         name = Person.objects(_id=person_id)[0].name
         print(name)
         if Person.objects(_id=person_id).delete():
             print('Deleted')
             return jsonify({'response': f'User {name} is deleted'})
     except Exception as e:
         return jsonify({'response': 'An error has occurred'})
Beispiel #2
0
 def put(self, person_id):
     data = api.payload
     # Convert String to ObjectID.
     data['sex'] = ObjectId(data['sex'])
     Person.objects(_id=person_id).update(**data)
     return jsonify(Person.objects(_id=data['_id']))