feat: enhance database management with new migration and database node functionalities, including CRUD operations and test cases

This commit is contained in:
lborv
2025-09-27 23:41:32 +03:00
parent 0d5b2830ed
commit 785a7bfe8e
21 changed files with 333 additions and 189 deletions

View File

@ -61,6 +61,16 @@ export class DatabaseNodeService extends DatabaseEncryptionService {
username: string,
password: string
): Promise<DatabaseNode> {
const existingNode = await this.databaseNodeRepository.findOne({
where: { host, port },
});
if (existingNode) {
existingNode.password = this.encryptPassword(password);
existingNode.username = username;
return this.databaseNodeRepository.save(existingNode);
}
const encryptedPassword = this.encryptPassword(password);
const databaseNode = this.databaseNodeRepository.create({
host,
@ -68,6 +78,7 @@ export class DatabaseNodeService extends DatabaseEncryptionService {
username,
password: encryptedPassword,
});
return this.databaseNodeRepository.save(databaseNode);
}
@ -81,7 +92,7 @@ export class DatabaseNodeService extends DatabaseEncryptionService {
return {
host: node.host,
port: node.port,
username: node.username,
user: node.username,
password: this.decryptPassword(node.password),
};
}