typeorm#Entity TypeScript Examples
The following examples show how to use
typeorm#Entity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: log.entity.ts From 42_checkIn with GNU General Public License v3.0 | 6 votes |
@Entity()
export class Log {
constructor(user: User, card: Card, type: string) {
this.user = user;
this.card = card;
this.logType = type;
}
@PrimaryGeneratedColumn()
private logId: number;
@ManyToOne(() => User)
@JoinColumn()
private user: User;
@RelationId((log: Log) => log.card)
private cardId: number;
@ManyToOne(() => Card)
@JoinColumn()
private card: Card;
@Column()
private logType: string;
@CreateDateColumn()
private createdAt: Date;
@UpdateDateColumn()
private updatedAt: Date;
@DeleteDateColumn()
private deletedAt: Date;
}
Example #2
Source File: account.ts From TypeScript-Login-Register with MIT License | 6 votes |
@Entity()
export class Account {
@PrimaryGeneratedColumn()
id: number;
@Column()
username: string;
@Column()
password: string;
@OneToOne(() => AccountValidation)
@JoinColumn()
validation: AccountValidation;
}
Example #3
Source File: Handle.ts From bluebubbles-server with Apache License 2.0 | 6 votes |
@Entity("handle")
export class Handle {
@PrimaryGeneratedColumn({ name: "ROWID" })
ROWID: number;
@OneToMany(type => Message, message => message.handle)
@JoinColumn({ name: "ROWID", referencedColumnName: "handle_id" })
messages: Message[];
@ManyToMany(type => Chat)
@JoinTable({
name: "chat_handle_join",
joinColumns: [{ name: "handle_id" }],
inverseJoinColumns: [{ name: "chat_id" }]
})
chats: Chat[];
@Column({ type: "text", nullable: false })
id: string;
@Column({ type: "text", nullable: true })
country: string;
@Column({ type: "text", nullable: false, default: "iMessage" })
service: string;
@Column({ name: "uncanonicalized_id", type: "text", nullable: true })
uncanonicalizedId: string;
}
Example #4
Source File: guestRequest.ts From Corsace with MIT License | 6 votes |
@Entity()
export class GuestRequest extends BaseEntity {
@PrimaryGeneratedColumn()
ID!: number;
@ManyToOne(() => MCA, {
nullable: false,
eager: true,
})
mca!: MCA;
@ManyToOne(() => ModeDivision, modeDivision => modeDivision.guestRequests, {
nullable: false,
eager: true,
})
mode!: ModeDivision;
@Column({ type: "enum", enum: RequestStatus, default: RequestStatus.Pending })
status!: RequestStatus
@ManyToOne(() => User, user => user.guestRequests, {
nullable: false,
})
user!: User;
@ManyToOne(() => Beatmap, beatmap => beatmap.guestRequests, {
nullable: false,
eager: true,
})
@JoinTable()
beatmap!: Beatmap;
}
Example #5
Source File: newsletter-form.entity.ts From Cromwell with MIT License | 6 votes |
@Entity('PluginNewsletter_NewsletterForm')
@ObjectType('PluginNewsletter_NewsletterForm')
class PluginNewsletter_NewsletterForm implements NewsletterForm {
@Field(() => Int)
@PrimaryGeneratedColumn()
id: number;
@Field()
@Column()
email: string;
}
Example #6
Source File: Image.ts From NLW-3.0 with MIT License | 6 votes |
@Entity('images')
export default class Image {
@PrimaryGeneratedColumn('increment')
id: number;
@Column()
path: string;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
@ManyToOne(() => Orphanage, orphanage => orphanage.images)
@JoinColumn({ name: 'orphanage_id' })
orphanage: Orphanage;
}
Example #7
Source File: LoaderLog.ts From Designer-Server with GNU General Public License v3.0 | 6 votes |
/**
* @tsoaModel
*/
@Entity()
export class LoaderLog {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(type => Stage, {onDelete:'CASCADE'})
@JoinColumn()
stage: Stage;
@Column({type: "text", nullable: true})
content: string;
@Column({nullable: true})
message: string;
@Column({default: false})
isFailed: boolean;
@CreateDateColumn({ type: "timestamp" })
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}
Example #8
Source File: Appointment.ts From gobarber-api with MIT License | 6 votes |
@Entity('appointments')
class Appointment {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
provider_id: string;
@ManyToOne(() => User)
@JoinColumn({ name: 'provider_id' })
provider: User;
@Column()
user_id: string;
@ManyToOne(() => User)
@JoinColumn({ name: 'user_id' })
user: User;
@Column('timestamp with time zone')
date: Date;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}
Example #9
Source File: Image.ts From happy with MIT License | 6 votes |
@Entity('images')
export default class Image {
@PrimaryGeneratedColumn('increment')
id: number;
@Column()
path: string;
@ManyToOne(() => Orphanage, orphanage => orphanage.images)
@JoinColumn({ name: 'orphanage_id' })
orphanage: Orphanage;
}
Example #10
Source File: Category.ts From rocketseat-gostack-11-desafios with MIT License | 6 votes |
@Entity('categories')
class Category {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
title: string;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}
Example #11
Source File: ActionType.ts From context-mod with MIT License | 6 votes |
@Entity()
export class ActionType {
@PrimaryGeneratedColumn()
id!: number;
@Column("varchar", {length: 200})
name!: string
constructor(name?: string) {
if(name !== undefined) {
this.name = name;
}
}
}
Example #12
Source File: cart-item.ts From nodeJS-express-postgresql with MIT License | 6 votes |
@Entity()
export class CartItem extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column('smallint', { nullable: false })
quantity: number;
@ManyToOne(() => Cart, cart => cart.cItem, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
@JoinColumn({ name: 'cartid' })
cartid: Cart;
@ManyToOne(() => Product, prod => prod.cItem, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
@JoinColumn({ name: 'productid' })
prodid: Product;
}
Example #13
Source File: PostLike.ts From jaebook-server with MIT License | 6 votes |
@Entity({ name: "post_like" })
@Index(["postId", "userId"], { unique: true })
export class PostLike {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ name: "post_id", length: 36 })
postId: string;
@Column({ name: "user_id", length: 36 })
userId: string;
@ManyToOne((type) => Post, (post) => post.id, {
cascade: true,
onDelete: "CASCADE",
})
@JoinColumn({ name: "post_id" })
post: Post;
@ManyToOne((type) => User, (user) => user.id, {
cascade: true,
onDelete: "CASCADE",
})
@JoinColumn({ name: "user_id" })
user: User;
@CreateDateColumn({ name: "created_at" })
createdAt: Date;
@UpdateDateColumn({ name: "updated_at" })
updatedAt: Date;
}
Example #14
Source File: user.entity.ts From nestjs-api-example with MIT License | 6 votes |
@Entity()
export class User {
@PrimaryGeneratedColumn()
@ApiProperty({ description: 'id' })
id: number;
@Column({ length: 50 })
@ApiProperty({ description: '이름' })
firstName: string;
@Column({ length: 50 })
@ApiProperty({ description: '성' })
lastName: string;
@Column({ default: true })
@ApiProperty({ description: '활동' })
isActive: boolean;
static of(params: Partial<User>): User {
const user = new User();
Object.assign(user, params);
return user;
}
update(firstName: string, lastName: string, isActive: boolean): void {
this.firstName = firstName;
this.lastName = lastName;
this.isActive = isActive;
}
}
Example #15
Source File: Appointment.ts From hotseat-api with MIT License | 6 votes |
@Entity('appointments')
class Appointment {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column('uuid')
provider_id: string;
@Column('uuid')
customer_id: string;
@ManyToOne(() => User, user => user.appointments)
@JoinColumn({ name: 'customer_id' })
customer: User;
@Column('timestamp with time zone')
date: Date;
@Column({
type: 'enum',
enum: APPOINTMENT_TYPES,
default: `${APPOINTMENT_TYPES[0]}`,
})
type: AppointmentType;
@CreateDateColumn({ type: 'timestamp' })
created_at: Date;
@UpdateDateColumn({ type: 'timestamp' })
updated_at: Date;
}
Example #16
Source File: comments.entity.ts From NestJs-youtube with MIT License | 6 votes |
@Entity({ name: 'comments' })
export class CommentEntity extends GenericEntity {
constructor(entityManager: EntityManager) {
super();
}
@PrimaryGeneratedColumn()
id: number;
@Column('text')
body: string;
@ManyToOne(
() => UserEntity,
(user: UserEntity) => user.posts,
{ onUpdate: 'CASCADE', onDelete: 'CASCADE' },
)
@JoinColumn({ name: 'user_id' })
user: UserEntity;
@ManyToOne(
() => PostEntity,
(post: PostEntity) => post.comments,
{ onUpdate: 'CASCADE', onDelete: 'CASCADE' },
)
@JoinColumn({ name: 'post_id' })
post: PostEntity;
}
Example #17
Source File: user.entity.ts From nest-js-boilerplate with MIT License | 6 votes |
@Entity('users')
export default class UserEntity {
@ApiProperty({ type: String })
@PrimaryGeneratedColumn()
readonly id: number = 1;
@ApiProperty({ type: String, maxLength: 64 })
@Column({ length: 64 })
readonly password: string = '';
@ApiProperty({ type: String, maxLength: 64 })
@Column({ length: 64 })
@Index({ unique: true })
readonly email: string = '';
@ApiProperty({ type: Boolean })
@Column({ type: 'tinyint' })
readonly verified: boolean = false;
@ApiProperty({ type: String, default: RolesEnum.user, enum: RolesEnum })
@Column({ type: 'enum', enum: RolesEnum, default: RolesEnum.user })
readonly role: RolesEnum = RolesEnum.user;
}
Example #18
Source File: BomLicenseException.ts From barista with Apache License 2.0 | 6 votes |
@Entity()
export class BomLicenseException extends BomItemBase {
/**
* A convenience association to the license since there is no relationship with a LicenseScanResultItem
*/
@ApiProperty()
@OneToOne(type => License, {
eager: true,
nullable: false,
onDelete: 'NO ACTION',
})
@JoinColumn()
license: License;
/**
* Corresponds to the path field on the LicenseScanResultItem
*/
@Column()
@ApiProperty()
licenseItemPath: string;
@ApiProperty({ type: type => Project })
@ManyToOne(type => Project, project => project.licenseExceptions, {
eager: true,
onDelete: 'CASCADE',
})
project: Project;
/**
* The ProjectScanStatus
*/
@ApiProperty({ type: type => ProjectScanStatusType })
@ManyToOne(type => ProjectScanStatusType, { eager: true })
@JoinColumn({
name: 'project_scan_status_type_code',
referencedColumnName: 'code',
})
projectScanStatus: ProjectScanStatusType;
}