Adding Date and working on fereign keys
This commit is contained in:
@@ -24,8 +24,13 @@ class Individual(BaseModel):
|
||||
|
||||
|
||||
class Employee(BaseModel):
|
||||
entity_id: str
|
||||
role: str
|
||||
entity_id: str = Field(foreignKey={
|
||||
"reference": {
|
||||
"resource": "entity",
|
||||
"fields": "_id"
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
class Corporation(BaseModel):
|
||||
@@ -46,6 +51,7 @@ class Entity(Document):
|
||||
|
||||
class Settings:
|
||||
bson_encoders = {
|
||||
date: lambda dt: datetime(year=dt.year, month=dt.month, day=dt.day, hour=0, minute=0, second=0) \
|
||||
if not hasattr(dt, 'hour') else dt
|
||||
date: lambda dt: dt if hasattr(dt, 'hour')
|
||||
else datetime(year=dt.year, month=dt.month, day=dt.day,
|
||||
hour=0, minute=0, second=0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user