I am trying to store temporal data in mongodb with the use of mongoengine. As the date of the data is a primary component, I thought it would be best to map the data to the date. However, when creating the document I receive an error that states Argument to MapField constructor must be a valid field.
I thought a datetime field was a valid field type given that DateTimeField exists in mongoengine. And reading further into the mongoengine Mapfield documentation, I have a suspicion that I am using it wrong.
Is it possible to map data to a datetime field for storage in mongoengine?
code
from datetime import datetime
from mongoengine import StringField, MapField, EmbeddedDocument, FloatField, IntField
class PlaySession(EmbeddedDocument):
hours_played = FloatField(db_field="hoursPlayed")
enjoyment = IntField(db_field="enjoyment")
number_of_players = IntField(db_field="playerNum")
class GameDoc(Document):
game = StringField(db_field="game")
console = StringField(db_field="console")
sessions = MapField(datetime, PlaySession, db_field="sessions")