mirror of https://github.com/MaxLeiter/Drift
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			79 lines
		
	
	
		
			1008 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			79 lines
		
	
	
		
			1008 B
		
	
	
	
		
			TypeScript
		
	
import {
 | 
						|
	BelongsToMany,
 | 
						|
	Column,
 | 
						|
	CreatedAt,
 | 
						|
	DataType,
 | 
						|
	HasMany,
 | 
						|
	IsUUID,
 | 
						|
	Model,
 | 
						|
	PrimaryKey,
 | 
						|
	Scopes,
 | 
						|
	Table,
 | 
						|
	Unique,
 | 
						|
	UpdatedAt
 | 
						|
} from "sequelize-typescript"
 | 
						|
import { PostAuthor } from "./PostAuthor"
 | 
						|
import { User } from "./User"
 | 
						|
import { File } from "./File"
 | 
						|
 | 
						|
@Scopes(() => ({
 | 
						|
	user: {
 | 
						|
		include: [
 | 
						|
			{
 | 
						|
				model: User,
 | 
						|
				through: { attributes: [] }
 | 
						|
			}
 | 
						|
		]
 | 
						|
	},
 | 
						|
	full: {
 | 
						|
		include: [
 | 
						|
			{
 | 
						|
				model: User,
 | 
						|
				through: { attributes: [] }
 | 
						|
			},
 | 
						|
			{
 | 
						|
				model: File,
 | 
						|
				through: { attributes: [] }
 | 
						|
			}
 | 
						|
		]
 | 
						|
	}
 | 
						|
}))
 | 
						|
@Table(
 | 
						|
	{
 | 
						|
		tableName: "posts",
 | 
						|
	}
 | 
						|
)
 | 
						|
export class Post extends Model {
 | 
						|
	@IsUUID(4)
 | 
						|
	@PrimaryKey
 | 
						|
	@Unique
 | 
						|
	@Column({
 | 
						|
		type: DataType.UUID,
 | 
						|
		defaultValue: DataType.UUIDV4
 | 
						|
	})
 | 
						|
	id!: string
 | 
						|
 | 
						|
	@Column
 | 
						|
	title!: string
 | 
						|
 | 
						|
	@BelongsToMany(() => User, () => PostAuthor)
 | 
						|
	users?: User[]
 | 
						|
 | 
						|
	@HasMany(() => File, { constraints: false })
 | 
						|
	files?: File[]
 | 
						|
 | 
						|
	@CreatedAt
 | 
						|
	@Column
 | 
						|
	createdAt!: Date
 | 
						|
 | 
						|
	@Column
 | 
						|
	visibility!: string
 | 
						|
 | 
						|
	@Column
 | 
						|
	password?: string
 | 
						|
 | 
						|
	@UpdatedAt
 | 
						|
	@Column
 | 
						|
	updatedAt!: Date
 | 
						|
}
 |