diff --git a/README.md b/README.md index 43e9877..81334be 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,8 @@ loopbackClientWithAuth.createToken() replaceOrCreate(data) + remote(customRoute,data) -> your customRoute name (example: greet) see https://loopback.io/doc/en/lb3/Remote-methods.html + diff --git a/dist/LoopbackModel.js b/dist/LoopbackModel.js index 9e4b99e..00b5989 100644 --- a/dist/LoopbackModel.js +++ b/dist/LoopbackModel.js @@ -193,6 +193,18 @@ var LoopbackModel = function () { var url = this.baseUrl + '/' + this.model + '/' + id; return this.del(url); } + }, { + key: 'upsertWithWhere', + value: function upsertWithWhere(query, data) { + var url = this.baseUrl + '/' + this.model + '/upsertWithWhere'; + return this.post(url, data, query); + } + }, { + key: 'replaceOrCreate', + value: function replaceOrCreate(data) { + var url = this.baseUrl + '/' + this.model + '/replaceOrCreate'; + return this.post(url, data); + } }]); return LoopbackModel; diff --git a/src/LoopbackModel.js b/src/LoopbackModel.js index 9aec0a3..494b3e9 100644 --- a/src/LoopbackModel.js +++ b/src/LoopbackModel.js @@ -190,6 +190,11 @@ class LoopbackModel { const url = `${this.baseUrl}/${this.model}/replaceOrCreate`; return this.post(url,data); } + + remote(name,data) { + const url = `${this.baseUrl}/${this.model}/${name}`; + return this.post(url,data); + } }