def update(self, id): schema = UserSchema() # Load update data, then find and update user update_data = schema.load_data(request.form) user = User.query.get(id) user.update_fields(update_data) db.session.commit() # Return success return jsonify(schema.dump_data(user))
def create(self): schema = UserSchema() # Load user data user = schema.load_data(request.form) # Add to database db.session.add(user) db.session.commit() # Return success return jsonify(schema.dump_data(user))