Comments (5)
我在本地测试中没有遇到此错误:
curl -X 'GET' \
'http://127.0.0.1:8000/api/v1/depts/1' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDQ5NzkwMjUsInN1YiI6IjIifQ.0ciKz_asssLjZw7B-F7q-ZCT_OPtlW2JuLy1XvoKRwg'
{
"code": 200,
"msg": "请求成功",
"data": {
"name": "test",
"parent_id": null,
"sort": 0,
"leader": null,
"phone": null,
"email": null,
"status": 1,
"id": 1,
"del_flag": false,
"created_time": "2023-06-26T17:13:45",
"updated_time": "2023-08-11T15:18:33"
}
}
from fastapi_best_architecture.
我们有一个关于 CRUDBase 的讨论:#267
如果你有兴趣,欢迎提供建议
from fastapi_best_architecture.
这是我的 model,
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime
from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column
from backend.app.models.base import DataClassBase, id_key
from backend.app.utils.timezone import timezone
class Knowledge(DataClassBase):
"""
知识库表
"""
__tablename__ = 'knowledge'
dept_id: Mapped[int | None] = mapped_column(comment='部门ID')
id: Mapped[id_key] = mapped_column(init=False)
name: Mapped[str] = mapped_column(String(52),default=None,comment='知识库名称')
description: Mapped[str | None] = mapped_column(String(255),default=None,comment='描述')
model: Mapped[str | None] = mapped_column(String(32),default=None,comment='模型')
index_name: Mapped[str | None] = mapped_column(String(32),default=None,comment='索引名称')
collection_name: Mapped[str | None] = mapped_column(String(32),default=None,comment='集合名称')
is_partition: bool = True
created_time: Mapped[datetime] = mapped_column(init=False, default_factory=timezone.now, comment='创建时间')
updated_time: Mapped[datetime] = mapped_column(init=False, default_factory=timezone.now, comment='更新时间')
目前卡在了result = await db.execute(select(self.model).where(and_(*where_list)))
from fastapi_best_architecture.
is_partition: bool = True
?
Why not is_partition: Mapped[bool] = mapped_column(default=True)
?
你尝试过使用await db.execute(select(self.model).where(self.model.id == pk))
是否能正确返回码?
另外,你完全可以继承 Base,从而省略手动编写的 created_time 和 updated_time
from fastapi_best_architecture.
If there is no feedback, I will close this problem.
from fastapi_best_architecture.
Related Issues (20)
- Optimize role menu authorization logic
- UUID exception HOT 17
- how to make pytest passed HOT 2
- AccessMiddleware and OperaLogMiddleware cannot exist at the same time. HOT 4
- celery task exception HOT 8
- Argument 'value' has incorrect type (expected str, got UUID) HOT 1
- ✨ TODO HOT 7
- opera_log_middleware exception
- 📣 Welcome aboard
- 建议新增代码生成功能 HOT 1
- some things HOT 1
- use pydantic EmailStr for email validation HOT 4
- demo 网站出问题了: 内部服务器错误。 HOT 5
- ✨ New backend architecture HOT 1
- Dynamic Configuration: Dynamic configuration of the system environment (site title, logo, filing, footer...)
- Nice project and some personal issue. HOT 2
- 安装过依赖之后,我直接在backend下面执行main.py报错,提示ModuleNotFoundError: No module named 'backend' HOT 2
- ❔ questions database HOT 5
- Celery with asyncio? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi_best_architecture.