在我的controller.ts
@Get()
getFuga(@Query() query: { place: string }): string {
return query.place
}
当我通过query
投掷GET
http://localhost:3000/event?place=Tokyo
响应为Tokyo
我想通过类似的查询来获得结果
select * from events where events.place = 'Tokyo'
有什么好的方法可以实现连接DB
并引发查询吗?
我是初学者,如果存在一些有用的材料,我可以伸出援手吗?
mysql> select * from events;
+----+--------+------------+---------+--------+-------------+------------+----------+----------+----------------------------+----------------------------+------------+---------+
| id | title | date | place | detail | is_lastdate | begin_time | end_time | label_cd | created_at | updated_at | deleted_at | user_id |
+----+--------+------------+---------+--------+-------------+------------+----------+----------+----------------------------+----------------------------+------------+---------+
| 1 | mytest | 2000-12-31 | Tottori | test | 1 | 11:59:00 | 23:40:00 | 4 | 2020-10-04 02:46:05.834987 | 2020-10-04 13:08:29.000000 | NULL | NULL |
| 2 | mytest | 2000-12-31 | Tokyo | test | 1 | 11:59:00 | 23:40:00 | 4 | 2020-10-04 02:46:05.834987 | 2020-10-04 13:08:19.000000 | NULL | NULL |
| 3 | mytest | 2020-07-06 | Tokyo | test | 0 | 00:00:00 | 00:00:00 | 0 | 2020-10-04 02:46:05.834987 | 2020-10-04 02:46:05.901008 | NULL | NULL |
| 4 | mytest | 2020-07-06 | Tokyo | test | 0 | 00:00:00 | 00:00:00 | 0 | 2020-10-04 02:46:05.834987 | 2020-10-04 02:46:05.901008 | NULL | NULL |
| 5 | mytest | 2000-12-31 | Tokyo | NULL | 0 | 00:00:00 | 00:00:00 | 0 | 2020-10-04 02:46:05.834987 | 2020-10-04 02:46:05.901008 | NULL | NULL |
| 6 | mytest | 2000-12-31 | Tokyo | NULL | 0 | 00:00:00 | 00:00:00 | 0 | 2020-10-04 02:46:05.834987 | 2020-10-04 02:46:05.901008 | NULL | NULL |
| 7 | mytest | 2000-12-31 | Tokyo | NULL | 0 | 00:00:00 | 00:00:00 | 0 |
+----+--------+------------+---------+--------+-------------+------------+----------+----------+----------------------------+----------------------------+------------+---------+
如果有人有意见,请告诉我。
谢谢