1
我一直在使用MapField可至今爲:Mongoengine:動態的字段EmbededDocuments作爲值
class Game(EmbeddedDocument):
iscomplete = BooleanField()
score = IntField()
#other not dynamic fields
class Progress(Document):
user = ReferenceField(User, dbref=True)
games = MapField(EmbeddedDocumentField(Game))
created_at = DateTimeField()
updated_on = DateTimeField()
我需要遊戲轉換爲ReferenceField。
我想創建一個動態字段/密鑰,但embeddedDocument爲值文件,讓我能有這樣一個文件:
{
"game1": {
"iscomplete": true,
"score": 23,
},
"game2": {
"iscomplete": false,
"score": 10,
}
}
爲T這裏反正我可以實現嗎?