Repairing Date & Datetime components
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from enum import Enum
|
||||
from datetime import datetime, date
|
||||
from typing import List, Literal
|
||||
from typing import List, Literal, Optional
|
||||
|
||||
from pymongo import TEXT, IndexModel
|
||||
from pydantic import Field, BaseModel, validator
|
||||
@@ -64,8 +64,8 @@ class Institution(BaseModel):
|
||||
|
||||
class Entity(Document):
|
||||
_id: str
|
||||
address: Indexed(str, index_type=TEXT)
|
||||
entity_data: Individual | Corporation | Institution = Field(..., discriminator='type')
|
||||
address: Optional[str] = ""
|
||||
label: str = None
|
||||
|
||||
@validator("label", always=True)
|
||||
@@ -79,7 +79,7 @@ class Entity(Document):
|
||||
bson_encoders = {
|
||||
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)
|
||||
hour=0, minute=0, second=0)
|
||||
}
|
||||
|
||||
fulltext_search = ['label']
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import uuid
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from .models import Entity, EntityType, Individual, Corporation
|
||||
@@ -12,10 +10,10 @@ class EntityRead(Entity):
|
||||
|
||||
|
||||
class EntityCreate(Writer):
|
||||
address: str
|
||||
entity_data: Individual | Corporation = Field(..., discriminator='type')
|
||||
address: Optional[str] = ""
|
||||
|
||||
|
||||
class EntityUpdate(BaseModel):
|
||||
address: str
|
||||
entity_data: Individual | Corporation = Field(..., discriminator='type')
|
||||
address: Optional[str] = ""
|
||||
|
||||
Reference in New Issue
Block a user