例如,我有一个TypeORM实体Profile
:
@Entity()
class Profile {
@PrimaryGeneratedColumn()
id: number;
@Column()
gender: string;
@Column()
photo: string;
@OneToOne(type => User, { cascade: true })
@JoinColumn()
user: User;
}
Run Code Online (Sandbox Code Playgroud)
我不确定应该使用哪一个删除用户个人资料?
Profile.remove(profile)
Profile.delete(profile)
Run Code Online (Sandbox Code Playgroud)
TypeORM中remove
和delete
方法之间有什么区别?
在{ port }
我得到错误:键入 'string | AddressInfo' 没有属性 'port',也没有字符串索引签名。
如何解决?
代码:
import * as express from 'express'
const app = express()
app.listen({ port: process.env.PORT })
const { port } = app.address()
Run Code Online (Sandbox Code Playgroud)
我的 tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
"sourceMap": true,
"outDir": "./dist",
"moduleResolution": "node",
"composite": true,
"removeComments": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"baseUrl": ".." …
Run Code Online (Sandbox Code Playgroud) 当我部署我的服务器时出现错误
server_1 | (node:9) UnhandledPromiseRejectionWarning: /usr/app/packages/server/dist/modules/listing/create/resolvers.d.ts:1
server_1 | (function (exports, require, module, __filename, __dirname) { import { MutationResolvers } from '../../../types';
server_1 | ^
server_1 |
server_1 | SyntaxError: Unexpected token {
Run Code Online (Sandbox Code Playgroud)
我的解决方案(它有效)是删除*.d.ts
任何地方的所有文件。这是我的packages.json
脚本及其质量
"build": "tsc -b && copyfiles -u 1 src/**/*.graphql dist/ && rimraf ./dist/*.d.ts && rimraf ./dist/**/*.d.ts && rimraf ./dist/**/**/*.d.ts && rimraf ./dist/**/**/**/*.d.ts"
Run Code Online (Sandbox Code Playgroud)
如何*.d.ts
在dist
没有文件夹嵌套的情况下删除文件夹中的所有文件?
如何在 0.5.0 solidity 编译器版本中返回字符串?
contract Test {
string public text = 'show me';
function test() public view returns (string) {
return text;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
TypeError: Data location must be "memory" for return parameter in function, but none was given.
Run Code Online (Sandbox Code Playgroud)