2
class Users(db.Document, UserMixin):
first_name = db.StringField()
last_name = db.StringField()
username = db.StringField(unique=True)
password = db.StringField()
email = db.StringField()
following = db.ListField(db.StringField(), default=[])
role = db.ListField(db.StringField(), default=["user"])
confirmed = db.BooleanField(default=False)
confirmed_on = db.DateTimeField()
,所以如果我想從Users.following
場
Users.objects(username="some_user").update(pull__following=["some_string"])
刪除某個字符串,然後保存呢?
,因爲我已經嘗試這樣做,如果你想從你的列表中刪除一個元素,它不會從following
listField
所以這就是爲什麼。 'pull'將只取一個值,而'pull_al'l取一個'list'或'tuple' – Zion