Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Fonoster Team committed Mar 30, 2019
1 parent fa2ef06 commit e272366
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mod/data_api/peers_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit e272366

Please sign in to comment.