We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 868c708 commit 2e33b6cCopy full SHA for 2e33b6c
coronavirus/crud.py
@@ -27,7 +27,9 @@ def create_city(db: Session, city: schemas.CreateCity):
27
return db_city
28
29
30
-def get_data(db: Session, skip: int = 0, limit: int = 10):
+def get_data(db: Session, city: str = None, skip: int = 0, limit: int = 10):
31
+ if city:
32
+ return db.query(models.Data).filter(models.Data.city.has(province=city)) # 外键关联查询,这里不是像Django ORM那样Data.city.province
33
return db.query(models.Data).offset(skip).limit(limit).all()
34
35
0 commit comments