I want to remove ReferenceField value in mongoengine
My Model:
class User(db.Document):
name = StringField(required=True)
last_name = StringField()
address_ref = ReferenceField(Address)
class Adress(db.Document):
street = StringField()
city = StringField()
state = StringField()
Unfortunately in mongengine documentation. There is not much information about unset. So I'm trying something like this
User.update(id=ObjectId("59ca38c5d1174d081c9bcaca")).unset(address_ref="").first()
but I have an error
TypeError: update() missing 1 required positional argument: 'self'
My Document
{
"_id": {
"$oid": "59ca38c5d1174d081c9bcaca"
},
"name": "Amanda",
"last_name": "Barow",
"address_ref": {
"$oid": "59ca38c9d1174d081c9bcad7"
}
},
{
"_id": {
"$oid": "59ca38c4d1174d081c9bcac9"
},
"name": "Larry",
"last_name": "Denor",
"address_ref": {
"$oid": "59c8f34200fc624a0168c4bc"
}
}
I want to get this effect (Amanda adress_ref = "" )
{
"_id": {
"$oid": "59ca38c5d1174d081c9bcaca"
},
"name": "Amanda",
"last_name": "Barow",
"address_ref": ""
},
{
"_id": {
"$oid": "59ca38c4d1174d081c9bcac9"
},
"name": "Larry",
"last_name": "Denor",
"address_ref": {
"$oid": "59c8f34200fc624a0168c4bc"
}
}