Skip to content

Commit

Permalink
Merge pull request #161 from akrstova/#135-bug-add-to-collection
Browse files Browse the repository at this point in the history
Fix: do not throw exception upon database warning
  • Loading branch information
muralikrishna8 authored Feb 12, 2020
2 parents 770d0cb + 3ed9eff commit a3c7546
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions server/src/CouchClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export default class CouchClient {
constructor(accessToken, dbName, dbUrl) {
this.accessToken = accessToken;
this.dbUrl = dbUrl || ApplicationConfig.instance().dbUrl();
if(dbName) {
if (dbName) {
this.dbName = dbName;
} else if(accessToken) {
} else if (accessToken) {
const userInfo = userDetails.getUser(accessToken);
if(userInfo) {
if (userInfo) {
this.dbName = userInfo.dbName;
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ export default class CouchClient {

async deleteDocument(documentId, revision) {
let rev = revision;
if(!rev) {
if (!rev) {
const doc = await this.getDocument(documentId);
rev = doc._rev;
}
Expand All @@ -85,10 +85,11 @@ export default class CouchClient {
async findDocuments(query, customHeaders = {}) {
const path = "/" + this.dbName + "/_find";
const response = await this.post(path, query, customHeaders);
if(response.warning) {
throw { "message": "No matching index found" }; //eslint-disable-line no-throw-literal
if (response.warning) {
CouchClient.logger().warn("CouchClient:: " + response.warning);
}
return response;

}

createIndex(indexDoc, customHeaders = {}) {
Expand Down

0 comments on commit a3c7546

Please sign in to comment.