This code bellow:
.findOne({ id: model.userId })!;
does case sensitive comparing. I want to compare UUID with case insensitive.
How can I do this?
I am using MSSQL as the database. It stores GUID in lowercase. But there is a problem, TypeORM always returns Uppercased UUID.
For example:
let application = await applicationRepo.findOne({id: model.id, ownerId: res.locals.owner.id});
Returns this:
{
"id": "AFB3015E-BE49-EC11-AE4D-74D83E04F9D3",
"name": ".....",
"dateCreated": "1637384252132",
"status": "ACTIVE",
"ownerId": "96BBB111-BE49-EC11-AE4D-74D83E04F9D3"
}
If possible I want to set and get uuid in lowercase.
How can I do this?
This is the entity example:
@Entity()
export class Application {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column()
name: string;
@Column("bigint")
dateCreated: number;
@Column()
status: string;
@ManyToOne(type => Owner, owner => owner.applications)
@JoinColumn({ name: "ownerId" })
owner: Owner;
@Column()
ownerId: string;
@OneToMany(type => User, user => user.application)
users: User[];
@OneToMany(type => ChatRoom, chatRoom => chatRoom.application)
chatRooms: ChatRoom[];
}
You could modify it locally by using toLowerCase()
const data = {
"id": "AFB3015E-BE49-EC11-AE4D-74D83E04F9D3",
"name": ".....",
"dateCreated": "1637384252132",
"status": "ACTIVE",
"ownerId": "96BBB111-BE49-EC11-AE4D-74D83E04F9D3"
}
const result = { ...data, id: data.id.toLowerCase() };
console.log(result);