This is not really issue, but a question. I'm seriously confused, or I'm getting old.. Through all documentation I've found about MongoAlchemy and flask-mongoalchemy, I just don't understand how to remove from DB something simple as for example this:
class User(db.Document):
username = db.StringField()
password_hash = db.HashField()
and let's say there's already one row in db where username is 'holms'.
How can I remove it?? I mean completely delete whole row with password_hash too. In real system I usually avoid to remove users, but this is for unit testing.
My attempt:
users = User.query.filter(User.username=="holms")
----> 1 users.remove_all(User.username, ['holms'])
/var/www/msgapp/backend/lib/python2.7/site-packages/mongoalchemy/query.pyc in remove_all(self, qfield, *value)
387 def remove_all(self, qfield, *value):
388 ''' Refer to: :func:`~mongoalchemy.update_expression.UpdateExpression.remove_all`'''
--> 389 return UpdateExpression(self).remove_all(qfield, *value)
390
391 def add_to_set(self, qfield, value):
/var/www/msgapp/backend/lib/python2.7/site-packages/mongoalchemy/update_expression.pyc in remove_all(self, qfield, *value)
123 def remove_all(self, qfield, *value):
124 ''' Atomically remove each value in ``value`` from ``qfield``'''
--> 125 return self._atomic_list_op_multivalue('$pullAll', qfield, *value)
126
127 def add_to_set(self, qfield, value):
/var/www/msgapp/backend/lib/python2.7/site-packages/mongoalchemy/update_expression.pyc in _atomic_list_op_multivalue(self, op, qfield, *value)
147 qfield = resolve_name(self.query.type, qfield)
148 if op not in qfield.valid_modifiers:
--> 149 raise InvalidModifierException(qfield, op)
150 wrapped = []
151 for v in value:
InvalidModifierException: Invalid modifier for QueryField field: $pullAll
This is not really issue, but a question. I'm seriously confused, or I'm getting old.. Through all documentation I've found about MongoAlchemy and flask-mongoalchemy, I just don't understand how to remove from DB something simple as for example this:
and let's say there's already one row in db where username is 'holms'. How can I remove it?? I mean completely delete whole row with password_hash too. In real system I usually avoid to remove users, but this is for unit testing.
My attempt: