Updated the SQL file to support series subscriptions in the future, among other changes.

This commit is contained in:
Tom
2025-02-20 04:44:26 +00:00
parent cd3ba11924
commit 8f0ca1ce58
4 changed files with 71 additions and 52 deletions

View File

@ -1,9 +1,10 @@
import * as argon2 from 'argon2';
import * as crypto from 'crypto';
import { UUID } from "crypto";
import { BookStatusEntity } from 'src/books/books/entities/book-status.entity';
import { BigIntTransformer } from 'src/shared/transformers/bigint';
import { StringToLowerCaseTransformer } from 'src/shared/transformers/string';
import { BeforeInsert, Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { BeforeInsert, Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
@Entity({
name: 'users'
@ -18,17 +19,20 @@ export class UserEntity {
@Column({ name: 'user_name', nullable: false })
userName: string;
@Column({ nullable: false })
@Column({ name: 'password', nullable: false })
password: string;
@Column({ type: 'bigint', nullable: false, transformer: BigIntTransformer })
@Column({ name: 'salt', type: 'bigint', nullable: false, transformer: BigIntTransformer })
salt: BigInt;
@Column({ name: 'is_admin', nullable: false })
isAdmin: boolean;
@Column({ name: 'date_joined', type: 'timestamptz', nullable: false })
dateJoined: Date;
@Column({ name: 'joined_at', type: 'timestamptz', nullable: false })
joinedAt: Date;
@OneToMany(type => BookStatusEntity, bookStatus => bookStatus.userId)
bookStatuses: BookStatusEntity[];
@BeforeInsert()
async hashPassword() {

View File

@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { UsersService } from './users.service';
import { UserEntity } from './users.entity';
import { UserEntity } from './entities/users.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersController } from './users.controller';
import { ConfigModule } from '@nestjs/config';

View File

@ -2,7 +2,7 @@ import * as argon2 from 'argon2';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { UserEntity } from './users.entity';
import { UserEntity } from './entities/users.entity';
import { LoginUserDto } from './dto/login-user.dto';
import { UUID } from 'crypto';
@ -11,7 +11,7 @@ class UserDto {
userLogin: string;
userName: string;
isAdmin: boolean;
dateJoined: Date;
joinedAt: Date;
}
@Injectable()
@ -28,7 +28,7 @@ export class UsersService {
userLogin: u.userLogin,
userName: u.userName,
isAdmin: u.isAdmin,
dateJoined: u.dateJoined,
joinedAt: u.joinedAt,
}));
}