From 22e2c8a1069f92a4f3fc075258127c6abda9e162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20GUILLY?= Date: Tue, 5 Jun 2018 14:01:47 +0200 Subject: [PATCH] add remote method --- README.md | 2 ++ dist/LoopbackModel.js | 12 ++++++++++++ src/LoopbackModel.js | 5 +++++ 3 files changed, 19 insertions(+) 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); + } }