Skip to content

Commit

Permalink
add remote method
Browse files Browse the repository at this point in the history
  • Loading branch information
sguilly committed Jun 5, 2018
1 parent d7e3175 commit 22e2c8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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




Expand Down
12 changes: 12 additions & 0 deletions dist/LoopbackModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/LoopbackModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down

0 comments on commit 22e2c8a

Please sign in to comment.