我阅读了以下文档描述的nest命令。
https://docs.nestjs.com/cli/scripts
根据该文件,必须添加以下内容package.json
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
Run Code Online (Sandbox Code Playgroud)
--watch和选项是什么--debug?
我的api-server Dockerfile正在关注
FROM node:alpine
WORKDIR /src
COPY . .
RUN rm -rf /src/node_modules
RUN rm -rf /src/package-lock.json
RUN yarn install
CMD yarn start:dev
Run Code Online (Sandbox Code Playgroud)
后 docker-compose up -d
我试过
$ docker exec -it api-server sh
/src # curl 'http://localhost:3000/'
sh: curl: not found
Run Code Online (Sandbox Code Playgroud)
为什么curl找不到命令?
我的主机是 Mac OS X。
我尝试将 null 设置为如下所示的列。
ALTER TABLE myschema.table ALTER COLUMN (test_id,type) SET NOT NULL;
但它返回语法错误,例如 Syntax error at or near Line 3, Position 47
有没有适当的方法来实现这一目标?
如果有人有意见请告诉我。
谢谢
我有如下表,我想改造它们。
year month week type count
2021 1 1 A 5
2021 1 1 B 6
2021 1 1 C 7
2021 1 2 A 0
2021 1 2 B 8
2021 1 2 C 9
Run Code Online (Sandbox Code Playgroud)
我想像下面这样旋转。
year month week A B C
2021 1 1 5 6 7
2021 1 2 0 8 9
Run Code Online (Sandbox Code Playgroud)
我尝试了以下语句,但它返回了很多空列。我想知道当添加新类型时我必须一一添加列。
select
year,
month,
week,
case when type in ('A') then count end as A,
case when type in ('B') then count end as B, …Run Code Online (Sandbox Code Playgroud) 当我参考此文档尝试连接数据库时,我使用 typeorm 开发了我的应用程序。
我尝试了以下示例,它返回了结果。
const datasource = new DataSource(LocalOrmconfig)
datasource.initialize()
.then(() => {
console.log("Data Source has been initialized!");
const result = datasource.getrepository(Sample).findone(query)
})
.catch((err) => {
console.error("Error during Data Source initialization", err);
});
Run Code Online (Sandbox Code Playgroud)
但以下没有返回结果。
文件说It's a good idea to make AppDataSource globally available by export-ing it, since you'll use this instance across your application.
我想datasource在任何地方使用,所以我想知道如何导出和使用datasource.
const datasource = new DataSource(LocalOrmconfig)
datasource.initialize()
.then(() => {
console.log("Data Source has been initialized!");
})
.catch((err) => { …Run Code Online (Sandbox Code Playgroud) 我有一个数据帧;
df=pd.DataFrame({'col1':[100000,100001,100002,100003,100004]})
col1
0 100000
1 100001
2 100002
3 100003
4 100004
Run Code Online (Sandbox Code Playgroud)
我希望我能得到以下结果;
col1 col2 col3
0 10 00 00
1 10 00 01
2 10 00 02
3 10 00 03
4 10 00 04
Run Code Online (Sandbox Code Playgroud)
每行显示分割的数字.我想这个数字应该转换为字符串,但我不知道下一步....我想问一下如何将数字拆分为单独的列.
我想在基于应用程序的应用程序中添加验证typeorm规则nest.js。
我的entity和dto正在关注。
我想要的验证如下
column data_type validation_rule
date DATE YYYY:HH:MM
begin_time TIME HH:MM
Run Code Online (Sandbox Code Playgroud)
我想知道如何添加TIME类型以及如何验证YYY:HH:MM
有什么办法可以实现这个验证规则吗typeorm?
我目前的工作如下
如果有人有意见请告诉我,谢谢
event.entity.ts
@Entity('events')
export class Event extends BaseEntity {
@PrimaryGeneratedColumn('increment', { type: 'int' })
id: number;
@Column('date')
date: Date;
@Column('date',{name: 'begin_time'})
beginTime: Date;
}
Run Code Online (Sandbox Code Playgroud)
event.dto.ts
export class eventRequest {
@IsInt()
id: number;
@IsDateString()
date: Date;
@IsDateString()
beginTime: Date;
}
Run Code Online (Sandbox Code Playgroud)
这是整个表格的详细信息。
mysql> desc events
-> ;
+--------------+--------------+------+-----+----------------------+----------------+
| Field | Type | Null …Run Code Online (Sandbox Code Playgroud) 我在 typeorm 中设置了以下查询生成器。
const sql = this.attendanceRepository
.createQueryBuilder("attendance")
.leftJoin("attendance.child", "child")
.select("attendance")
.addSelect("CONCAT_WS(' ', child.firstName, child.middleName, child.lastName)", "childName")
.addSelect("child.class")
.where("attendance.id= :id", { id: id})
.getRawOne()
const Result = await sql
Run Code Online (Sandbox Code Playgroud)
该查询生成器生成以下内容SQL
SELECT `attendance`.`id` AS `attendance_id`, `attendance`.`child_id` AS `attendance_child_id`,
`attendance`.`attendance_cd` AS `attendance_attendance_cd`, `attendance`.`come_home_time` AS `attendance_come_home_time`, `attendance`.`late_time` AS `attendance_late_time`, `attendance`.`memo` AS `attendance_memo`, `attendance`.`created_at` AS `attendance_created_at`,
`attendance`.`updated_at` AS `attendance_updated_at`, `attendance`.`deleted_at` AS `attendance_deleted_at`, `child`.`class` AS `child_class`,
CONCAT_WS(' ', `child`.`first_name`, `child`.`middle_name`, `child`.`last_name`) AS `childName`
FROM `attendances` `attendance`
LEFT JOIN `children` `child`
ON `child`.`id`=`attendance`.`child_id`
WHERE ( …Run Code Online (Sandbox Code Playgroud) 当我运行我的服务器时,我遇到了以下错误。
Error: Config validation error: "JWT_SECRET" is required. "JWT_EXPIRATION_TIME" is required
因此我必须设置 JWT 密钥等。
我想知道如何设置JWT_SECRET。但我不知道如何生成和设置它们。
我设置了.env文件,我必须在其中配置一些变量。
我的.env文件如下。
.env
JWT_SECRET=
JWT_EXPIRATION_TIME=
Run Code Online (Sandbox Code Playgroud)
如果有人知道生成的好方法SECRET请告诉我。
谢谢
我按如下方式设置示例 lambda 函数来检测什么是context. 该功能由API网关挂钩。
import json
def lambda_handler(event, context):
return {
'isBase64Encoded': False,
'statusCode': 200,
'headers': {},
'body': json.dumps(context)
}
Run Code Online (Sandbox Code Playgroud)
当我从 API 网关发送 GET 请求时,它返回如下
{
"message": "Internal server error"
}
Run Code Online (Sandbox Code Playgroud)
Mon May 24 07:20:58 UTC 2021 : Lambda execution failed with status 200 due to customer function error: Object of type LambdaContext is not JSON serializable. Lambda request id: 32d4e450-576b-4bd6-abb9-d1bd893077ed
Mon May 24 07:20:58 UTC 2021 : Method completed with status: 502
Run Code Online (Sandbox Code Playgroud)
context是不是json格式不对?我如何context …
sql ×3
typeorm ×3
typescript ×3
javascript ×2
nestjs ×2
postgresql ×2
alter-table ×1
aws-lambda ×1
dataframe ×1
ddl ×1
docker ×1
express ×1
mysql ×1
node.js ×1
numpy ×1
orm ×1
pandas ×1
python ×1
secret-key ×1
split ×1
validation ×1