Skip to content

Commit

Permalink
Improved insert and delete return values
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkAndFly committed Jul 29, 2021
1 parent f5199b5 commit e8172ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Actualiza el exchange en eur para una Billetera. Devuelve el objeto.

-----------------------------------------------------------------------------------------------------------------------------------------

Delete
DELETE
pametro: 'walletAddress': string,

Borra una Billetera.
Expand Down
7 changes: 4 additions & 3 deletions src/wallets/wallets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class WalletsService {
private httpService: HttpService,
) {}

async insertWallet(address: string, description: string) : Promise<string> {
async insertWallet(address: string, description: string) : Promise<boolean> {

if(await this.exist(address))
{ throw new HttpException({
Expand All @@ -43,7 +43,7 @@ export class WalletsService {

const result = await newWallet.save();

return 'wallet added successfully.';
return true;
}

async getAllWallets() {
Expand Down Expand Up @@ -90,13 +90,14 @@ export class WalletsService {
return wallet;
}

async removeWallet(walletAddress: string) {
async removeWallet(walletAddress: string) : Promise<boolean>{
const result = await this.walletModel
.deleteOne({ address: walletAddress })
.exec();
if (result.n === 0) {
throw new NotFoundException('Wallet not found');
}
return true;
}

private async findWallet(walletAddress: string): Promise<Wallet> {
Expand Down

0 comments on commit e8172ab

Please sign in to comment.