按照官方文档,我创建了小型 koa/typeorm/postgres 应用程序。当我使用createConnection配置,在同一个文件中导入实体时,应用程序工作正常,但 typeorm cli 找不到配置文件,所以我尝试将配置移动到“ormconfig.json”。现在我收到这个错误:
SyntaxError: Cannot use import statement outside a module
看起来 typeorm 无法使用 es6 功能。
我的ormconfig.json:
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": ****,
"password": ****,
"database": ****,
"synchronize": true,
"entities": ["src/entity/**/*.ts"],
"migrations": ["src/migration/**/*.ts"],
"subscribers": ["src/subscriber/**/*.ts"],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
}
}
Run Code Online (Sandbox Code Playgroud)
我的tsconfig.json:
{
"compilerOptions": {
"lib": ["es5", "es6"],
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
},
"exclude": ["node_modules"]
} …Run Code Online (Sandbox Code Playgroud) 我正在寻找方法来阻止用户在 django 管理页面中输入过去的日期。像这样的东西:
Django:如何将 DateField 设置为仅接受今天和未来日期
我的模型如下所示:
class MyModel(models.Model):
date = models.DateField(null=True, blank=True, default=None)
Run Code Online (Sandbox Code Playgroud)