Meta を二重にデータベースに保存できないように

This commit is contained in:
syuilo 2019-04-17 00:33:02 +09:00
parent e90ac5d6a4
commit 52e3bcfd29
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
2 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import { Meta } from '../models/entities/meta';
import { Metas } from '../models';
import { genId } from './gen-id';
export default async function(): Promise<Meta> {
const meta = await Metas.findOne();
@ -8,7 +7,7 @@ export default async function(): Promise<Meta> {
return meta;
} else {
return Metas.save({
id: genId(),
id: 'x'
} as Meta);
}
}

View File

@ -1,9 +1,11 @@
import { Entity, Column, PrimaryColumn } from 'typeorm';
import { id } from '../id';
@Entity()
export class Meta {
@PrimaryColumn(id())
@PrimaryColumn({
type: 'varchar',
length: 32
})
public id: string;
@Column('varchar', {