From e272366906d6a4db072c742864f607aa50ee0515 Mon Sep 17 00:00:00 2001 From: Fonoster Team Date: Fri, 29 Mar 2019 20:39:24 -0400 Subject: [PATCH] Code cleanup --- mod/data_api/peers_api.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mod/data_api/peers_api.js b/mod/data_api/peers_api.js index f826894ae..49ecb214e 100644 --- a/mod/data_api/peers_api.js +++ b/mod/data_api/peers_api.js @@ -12,14 +12,14 @@ export default class PeersAPI { this.ds = dataSource } - createFromJSON(jsonObj) { - return this.peerExist(jsonObj.spec.credentials.username)? CoreUtils.buildResponse(Status.CONFLICT):this.ds.insert(jsonObj) - } - updateFromJSON(jsonObj) { return !this.peerExist(jsonObj.spec.credentials.username)? CoreUtils.buildResponse(Status.NOT_FOUND):this.ds.update(jsonObj) } + createFromJSON(jsonObj) { + return this.peerExist(jsonObj.spec.credentials.username)? CoreUtils.buildResponse(Status.CONFLICT):this.ds.insert(jsonObj) + } + getPeers(filter) { return this.ds.withCollection('peers').find(filter) } @@ -28,14 +28,14 @@ export default class PeersAPI { return DSUtil.deepSearch(this.getPeers(), "metadata.ref", ref) } - getPeerByUsername(username) { - return DSUtil.deepSearch(this.getPeers(), "spec.credentials.username", username) - } - peerExist(username) { return DSUtil.objExist(this.getPeerByUsername(username)) } + getPeerByUsername(username) { + return DSUtil.deepSearch(this.getPeers(), "spec.credentials.username", username) + } + deletePeer(ref) { return this.ds.withCollection('peers').remove(ref) }