feat: enhance database management with new migration and database node functionalities, including CRUD operations and test cases
This commit is contained in:
@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user