Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
|
a529986c65 | |
|
c362bcf930 | |
|
64c88ab382 | |
|
4b5ac98379 | |
|
2120e96dbf | |
|
be758fa770 | |
|
b8fd18e217 | |
|
334b705c69 | |
|
4bfa461229 | |
|
4f8a372d2c | |
|
22ee132941 | |
|
1975481cb0 | |
|
c03161dfe0 | |
|
39771be12f | |
|
4ff55feb24 | |
|
0097580537 | |
|
4efca1f052 | |
|
2aff46a79a | |
|
6caf45d39e | |
|
acbe35879b | |
|
e5e4ba93ef | |
|
61f031aeb9 | |
|
59f70ab3ce |
|
@ -1,37 +0,0 @@
|
|||
<!--
|
||||
Questions:
|
||||
https://groups.google.com/forum/#!forum/loopbackjs
|
||||
https://gitter.im/strongloop/loopback
|
||||
Immediate support:
|
||||
https://strongloop.com/api-connect-faqs/
|
||||
https://strongloop.com/node-js/subscription-plans/
|
||||
-->
|
||||
|
||||
# Description/Steps to reproduce
|
||||
|
||||
<!--
|
||||
If feature: A description of the feature
|
||||
If bug: Steps to reproduce
|
||||
-->
|
||||
|
||||
# Link to reproduction sandbox
|
||||
|
||||
<!--
|
||||
Link to an app sandbox for reproduction
|
||||
|
||||
Note: Failure to provide a sandbox application for reproduction purposes will result in the issue being closed.
|
||||
-->
|
||||
|
||||
# Expected result
|
||||
|
||||
<!--
|
||||
Also include actual results if bug
|
||||
-->
|
||||
|
||||
# Additional information
|
||||
|
||||
<!--
|
||||
Copy+paste the output of these two commands:
|
||||
node -e 'console.log(process.platform, process.arch, process.versions.node)'
|
||||
npm ls --prod --depth 0 | grep loopback
|
||||
-->
|
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
labels: bug
|
||||
|
||||
---
|
||||
|
||||
<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨
|
||||
|
||||
HELP US HELP YOU, PLEASE
|
||||
- Do a quick search to avoid duplicate issues
|
||||
- Provide as much information as possible (reproduction sandbox, use case for features, etc.)
|
||||
- Consider using a more suitable venue for questions such as Stack Overflow, Gitter, etc.
|
||||
|
||||
Please fill in the *entire* template below.
|
||||
|
||||
-->
|
||||
|
||||
## Steps to reproduce
|
||||
|
||||
<!-- Describe how to reproduce the issue -->
|
||||
|
||||
## Current Behavior
|
||||
|
||||
<!-- Describe the observed result -->
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
<!-- Describe what did you expect instead, what is the desired outcome? -->
|
||||
|
||||
## Link to reproduction sandbox
|
||||
|
||||
<!--
|
||||
See https://loopback.io/doc/en/contrib/Reporting-issues.html#loopback-3x-bugs
|
||||
Note: Failure to provide a sandbox application for reproduction purposes will result in the issue being closed.
|
||||
-->
|
||||
|
||||
## Additional information
|
||||
|
||||
<!--
|
||||
Copy+paste the output of these two commands:
|
||||
node -e 'console.log(process.platform, process.arch, process.versions.node)'
|
||||
npm ls --prod --depth 0 | grep loopback
|
||||
-->
|
||||
|
||||
## Related Issues
|
||||
|
||||
<!-- Did you find other bugs that looked similar? -->
|
||||
|
||||
_See [Reporting Issues](http://loopback.io/doc/en/contrib/Reporting-issues.html) for more tips on writing good issues_
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
labels: feature
|
||||
|
||||
---
|
||||
|
||||
## Suggestion
|
||||
|
||||
<!-- A summary of what you'd like to see added or changed -->
|
||||
|
||||
## Use Cases
|
||||
|
||||
<!--
|
||||
What do you want to use this for?
|
||||
What shortcomings exist with current approaches?
|
||||
-->
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- Show how this would be used and what the behavior would be -->
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
TBD - will be filled by the team.
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
name: Question
|
||||
about: The issue tracker is not for questions. Please use Stack Overflow or other resources for help.
|
||||
labels: question
|
||||
|
||||
---
|
||||
|
||||
<!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨
|
||||
|
||||
THE ISSUE TRACKER IS NOT FOR QUESTIONS.
|
||||
|
||||
DO NOT CREATE A NEW ISSUE TO ASK A QUESTION.
|
||||
|
||||
Please use one of the following resources for help:
|
||||
|
||||
**Questions**
|
||||
|
||||
- https://stackoverflow.com/tags/loopbackjs
|
||||
- https://groups.google.com/forum/#!forum/loopbackjs
|
||||
- https://gitter.im/strongloop/loopback
|
||||
|
||||
**Immediate support**
|
||||
|
||||
- https://strongloop.com/api-connect-faqs/
|
||||
- https://strongloop.com/node-js/subscription-plans/
|
||||
|
||||
-->
|
|
@ -0,0 +1,11 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Report a security vulnerability
|
||||
url: https://loopback.io/doc/en/contrib/Reporting-issues.html#security-issues
|
||||
about: Do not report security vulnerabilities using GitHub issues. Please send an email to `reachsl@us.ibm.com` instead.
|
||||
- name: Get help on StackOverflow
|
||||
url: https://stackoverflow.com/tags/loopbackjs
|
||||
about: Please ask and answer questions on StackOverflow.
|
||||
- name: Join our mailing list
|
||||
url: https://groups.google.com/forum/#!forum/loopbackjs
|
||||
about: You can also post your question to our mailing list.
|
|
@ -1,25 +1,17 @@
|
|||
### Description
|
||||
|
||||
|
||||
#### Related issues
|
||||
|
||||
<!--
|
||||
Please use the following link syntaxes:
|
||||
Please provide a high-level description of the changes made by your pull request.
|
||||
|
||||
- connect to #49 (to reference issues in the current repository)
|
||||
- connect to strongloop/loopback#49 (to reference issues in another repository)
|
||||
Include references to all related GitHub issues and other pull requests, for example:
|
||||
|
||||
Fixes #123
|
||||
Implements #254
|
||||
See also #23
|
||||
-->
|
||||
|
||||
- connect to <link_to_referenced_issue>
|
||||
|
||||
### Checklist
|
||||
|
||||
<!--
|
||||
- Please mark your choice with an "x" (i.e. [x], see
|
||||
https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments)
|
||||
- PR's without test coverage will be closed.
|
||||
-->
|
||||
## Checklist
|
||||
|
||||
- [ ] DCO (Developer Certificate of Origin) [signed in all commits](https://loopback.io/doc/en/contrib/code-contrib.html)
|
||||
- [ ] `npm test` passes on your machine
|
||||
- [ ] New tests added or existing tests modified to cover all changes
|
||||
- [ ] Code conforms with the [style
|
||||
guide](http://loopback.io/doc/en/contrib/style-guide.html)
|
||||
- [ ] Code conforms with the [style guide](https://loopback.io/doc/en/contrib/style-guide-es6.html)
|
||||
- [ ] Commit messages are following our [guidelines](https://loopback.io/doc/en/contrib/git-commit-messages.html)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
- "12"
|
||||
- "14"
|
||||
|
|
135
CONTRIBUTING.md
135
CONTRIBUTING.md
|
@ -19,133 +19,20 @@ Contributing to `loopback-connector-remote` is easy. In a few simple steps:
|
|||
* Submit a pull request through Github.
|
||||
|
||||
|
||||
### Contributor License Agreement ###
|
||||
|
||||
### Developer Certificate of Origin
|
||||
|
||||
This project uses [DCO](https://developercertificate.org/). Be sure to sign off
|
||||
your commits using the `-s` flag or adding `Signed-off-By: Name<Email>` in the
|
||||
commit message.
|
||||
|
||||
**Example**
|
||||
|
||||
```
|
||||
Individual Contributor License Agreement
|
||||
|
||||
By signing this Individual Contributor License Agreement
|
||||
("Agreement"), and making a Contribution (as defined below) to
|
||||
StrongLoop, Inc. ("StrongLoop"), You (as defined below) accept and
|
||||
agree to the following terms and conditions for Your present and
|
||||
future Contributions submitted to StrongLoop. Except for the license
|
||||
granted in this Agreement to StrongLoop and recipients of software
|
||||
distributed by StrongLoop, You reserve all right, title, and interest
|
||||
in and to Your Contributions.
|
||||
|
||||
1. Definitions
|
||||
|
||||
"You" or "Your" shall mean the copyright owner or the individual
|
||||
authorized by the copyright owner that is entering into this
|
||||
Agreement with StrongLoop.
|
||||
|
||||
"Contribution" shall mean any original work of authorship,
|
||||
including any modifications or additions to an existing work, that
|
||||
is intentionally submitted by You to StrongLoop for inclusion in,
|
||||
or documentation of, any of the products owned or managed by
|
||||
StrongLoop ("Work"). For purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication
|
||||
sent to StrongLoop or its representatives, including but not
|
||||
limited to communication or electronic mailing lists, source code
|
||||
control systems, and issue tracking systems that are managed by,
|
||||
or on behalf of, StrongLoop for the purpose of discussing and
|
||||
improving the Work, but excluding communication that is
|
||||
conspicuously marked or otherwise designated in writing by You as
|
||||
"Not a Contribution."
|
||||
|
||||
2. You Grant a Copyright License to StrongLoop
|
||||
|
||||
Subject to the terms and conditions of this Agreement, You hereby
|
||||
grant to StrongLoop and recipients of software distributed by
|
||||
StrongLoop, a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
derivative works of, publicly display, publicly perform,
|
||||
sublicense, and distribute Your Contributions and such derivative
|
||||
works under any license and without any restrictions.
|
||||
|
||||
3. You Grant a Patent License to StrongLoop
|
||||
|
||||
Subject to the terms and conditions of this Agreement, You hereby
|
||||
grant to StrongLoop and to recipients of software distributed by
|
||||
StrongLoop a perpetual, worldwide, non-exclusive, no-charge,
|
||||
royalty-free, irrevocable (except as stated in this Section)
|
||||
patent license to make, have made, use, offer to sell, sell,
|
||||
import, and otherwise transfer the Work under any license and
|
||||
without any restrictions. The patent license You grant to
|
||||
StrongLoop under this Section applies only to those patent claims
|
||||
licensable by You that are necessarily infringed by Your
|
||||
Contributions(s) alone or by combination of Your Contributions(s)
|
||||
with the Work to which such Contribution(s) was submitted. If any
|
||||
entity institutes a patent litigation against You or any other
|
||||
entity (including a cross-claim or counterclaim in a lawsuit)
|
||||
alleging that Your Contribution, or the Work to which You have
|
||||
contributed, constitutes direct or contributory patent
|
||||
infringement, any patent licenses granted to that entity under
|
||||
this Agreement for that Contribution or Work shall terminate as
|
||||
of the date such litigation is filed.
|
||||
|
||||
4. You Have the Right to Grant Licenses to StrongLoop
|
||||
|
||||
You represent that You are legally entitled to grant the licenses
|
||||
in this Agreement.
|
||||
|
||||
If Your employer(s) has rights to intellectual property that You
|
||||
create, You represent that You have received permission to make
|
||||
the Contributions on behalf of that employer, that Your employer
|
||||
has waived such rights for Your Contributions, or that Your
|
||||
employer has executed a separate Corporate Contributor License
|
||||
Agreement with StrongLoop.
|
||||
|
||||
5. The Contributions Are Your Original Work
|
||||
|
||||
You represent that each of Your Contributions are Your original
|
||||
works of authorship (see Section 8 (Submissions on Behalf of
|
||||
Others) for submission on behalf of others). You represent that to
|
||||
Your knowledge, no other person claims, or has the right to claim,
|
||||
any right in any intellectual property right related to Your
|
||||
Contributions.
|
||||
|
||||
You also represent that You are not legally obligated, whether by
|
||||
entering into an agreement or otherwise, in any way that conflicts
|
||||
with the terms of this Agreement.
|
||||
|
||||
You represent that Your Contribution submissions include complete
|
||||
details of any third-party license or other restriction (including,
|
||||
but not limited to, related patents and trademarks) of which You
|
||||
are personally aware and which are associated with any part of
|
||||
Your Contributions.
|
||||
|
||||
6. You Don't Have an Obligation to Provide Support for Your Contributions
|
||||
|
||||
You are not expected to provide support for Your Contributions,
|
||||
except to the extent You desire to provide support. You may provide
|
||||
support for free, for a fee, or not at all.
|
||||
|
||||
6. No Warranties or Conditions
|
||||
|
||||
StrongLoop acknowledges that unless required by applicable law or
|
||||
agreed to in writing, You provide Your Contributions on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
|
||||
EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES
|
||||
OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
7. Submission on Behalf of Others
|
||||
|
||||
If You wish to submit work that is not Your original creation, You
|
||||
may submit it to StrongLoop separately from any Contribution,
|
||||
identifying the complete details of its source and of any license
|
||||
or other restriction (including, but not limited to, related
|
||||
patents, trademarks, and license agreements) of which You are
|
||||
personally aware, and conspicuously marking the work as
|
||||
"Submitted on Behalf of a Third-Party: [named here]".
|
||||
|
||||
8. Agree to Notify of Change of Circumstances
|
||||
|
||||
You agree to notify StrongLoop of any facts or circumstances of
|
||||
which You become aware that would make these representations
|
||||
inaccurate in any respect. Email us at callback@strongloop.com.
|
||||
git commit -s -m "feat: my commit message"
|
||||
```
|
||||
|
||||
Also see the [Contributing to LoopBack](https://loopback.io/doc/en/contrib/code-contrib.html) to get you started.
|
||||
|
||||
[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html
|
||||
[Google Javascript Style Guide]: https://google.github.io/styleguide/javascriptguide.xml
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// Copyright IBM Corp. 2014,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2014,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
'use strict';
|
||||
|
||||
/* global module:false */
|
||||
module.exports = function(grunt) {
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
|
|
10
README.md
10
README.md
|
@ -1,5 +1,14 @@
|
|||
# loopback-connector-remote
|
||||
|
||||
**THIS CONNECTOR DOES NOT SUPPORT LOOPBACK 4**
|
||||
|
||||
**⚠️ LoopBack 3 has reached end of life. We are no longer accepting pull requests or providing
|
||||
support for community users. The only exception is fixes for critical bugs and security
|
||||
vulnerabilities provided as part of support for IBM API Connect customers.
|
||||
We urge all LoopBack 3 users to migrate their applications to LoopBack 4 as soon as possible.
|
||||
Learn more about
|
||||
<a href="https://loopback.io/doc/en/contrib/Long-term-support.html">LoopBack's long term support policy.</a>**
|
||||
|
||||
The remote connector enables you to use a LoopBack application as a data source via REST.
|
||||
You can use the remote connector with a LoopBack application, a Node application, or a browser-based application that uses [LoopBack in the client](LoopBack-in-the-client.html).
|
||||
The connector uses [Strong Remoting](Strong-Remoting.html).
|
||||
|
@ -7,6 +16,7 @@ The connector uses [Strong Remoting](Strong-Remoting.html).
|
|||
In general, using the remote connector is more convenient than calling into REST API, and enables you to switch the transport later if you need to.
|
||||
|
||||
Use loopback-connector-remote:
|
||||
|
||||
- Version 3.x with LoopBack v3 and later.
|
||||
- Prior versions with LoopBack v2.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2014,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2014,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
@ -8,8 +8,8 @@
|
|||
/*!
|
||||
* Dependencies
|
||||
*/
|
||||
var relation = require('loopback-datasource-juggler/lib/relation-definition');
|
||||
var RelationDefinition = relation.RelationDefinition;
|
||||
const relation = require('loopback-datasource-juggler/lib/relation-definition');
|
||||
const RelationDefinition = relation.RelationDefinition;
|
||||
|
||||
module.exports = RelationMixin;
|
||||
|
||||
|
@ -75,7 +75,7 @@ function RelationMixin() {
|
|||
* @property {Object} model Model object
|
||||
*/
|
||||
RelationMixin.hasMany = function hasMany(modelTo, params) {
|
||||
var def = RelationDefinition.hasMany(this, modelTo, params);
|
||||
const def = RelationDefinition.hasMany(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
@ -139,7 +139,7 @@ RelationMixin.hasMany = function hasMany(modelTo, params) {
|
|||
*
|
||||
*/
|
||||
RelationMixin.belongsTo = function(modelTo, params) {
|
||||
var def = RelationDefinition.belongsTo(this, modelTo, params);
|
||||
const def = RelationDefinition.belongsTo(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
@ -179,31 +179,31 @@ RelationMixin.belongsTo = function(modelTo, params) {
|
|||
*/
|
||||
RelationMixin.hasAndBelongsToMany =
|
||||
function hasAndBelongsToMany(modelTo, params) {
|
||||
var def = RelationDefinition.hasAndBelongsToMany(this, modelTo, params);
|
||||
const def = RelationDefinition.hasAndBelongsToMany(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
||||
RelationMixin.hasOne = function hasOne(modelTo, params) {
|
||||
var def = RelationDefinition.hasOne(this, modelTo, params);
|
||||
const def = RelationDefinition.hasOne(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
||||
RelationMixin.referencesMany = function referencesMany(modelTo, params) {
|
||||
var def = RelationDefinition.referencesMany(this, modelTo, params);
|
||||
const def = RelationDefinition.referencesMany(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
||||
RelationMixin.embedsOne = function embedsOne(modelTo, params) {
|
||||
var def = RelationDefinition.embedsOne(this, modelTo, params);
|
||||
const def = RelationDefinition.embedsOne(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
||||
RelationMixin.embedsMany = function embedsMany(modelTo, params) {
|
||||
var def = RelationDefinition.embedsMany(this, modelTo, params);
|
||||
const def = RelationDefinition.embedsMany(this, modelTo, params);
|
||||
this.dataSource.adapter.resolve(this);
|
||||
defineRelationProperty(this, def);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2014,2018. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2014,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
@ -9,14 +9,14 @@
|
|||
* Dependencies.
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var remoting = require('strong-remoting');
|
||||
var utils = require('loopback-datasource-juggler/lib/utils');
|
||||
var jutil = require('loopback-datasource-juggler/lib/jutil');
|
||||
var RelationMixin = require('./relations');
|
||||
var InclusionMixin = require('loopback-datasource-juggler/lib/include');
|
||||
const assert = require('assert');
|
||||
const remoting = require('strong-remoting');
|
||||
const utils = require('loopback-datasource-juggler/lib/utils');
|
||||
const jutil = require('loopback-datasource-juggler/lib/jutil');
|
||||
const RelationMixin = require('./relations');
|
||||
const InclusionMixin = require('loopback-datasource-juggler/lib/include');
|
||||
|
||||
var findMethodNames = ['findById', 'findOne'];
|
||||
const findMethodNames = ['findById', 'findOne'];
|
||||
|
||||
/**
|
||||
* Export the RemoteConnector class.
|
||||
|
@ -48,7 +48,7 @@ function RemoteConnector(settings) {
|
|||
}
|
||||
|
||||
// handle mixins in the define() method
|
||||
var DAO = this.DataAccessObject = function() {
|
||||
const DAO = this.DataAccessObject = function() {
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ RemoteConnector.prototype.connect = function() {
|
|||
};
|
||||
|
||||
RemoteConnector.initialize = function(dataSource, callback) {
|
||||
var connector = dataSource.connector =
|
||||
const connector = dataSource.connector =
|
||||
new RemoteConnector(dataSource.settings);
|
||||
connector.connect();
|
||||
process.nextTick(callback);
|
||||
|
@ -110,19 +110,19 @@ RemoteConnector.prototype.setupRemotingTypeFor = function(Model) {
|
|||
};
|
||||
|
||||
function createProxyMethod(Model, remotes, remoteMethod) {
|
||||
var scope = remoteMethod.isStatic ? Model : Model.prototype;
|
||||
var original = scope[remoteMethod.name];
|
||||
const scope = remoteMethod.isStatic ? Model : Model.prototype;
|
||||
const original = scope[remoteMethod.name];
|
||||
|
||||
function remoteMethodProxy() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var lastArgIsFunc = typeof args[args.length - 1] === 'function';
|
||||
var callback;
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
const lastArgIsFunc = typeof args[args.length - 1] === 'function';
|
||||
let callback;
|
||||
if (lastArgIsFunc) {
|
||||
callback = args.pop();
|
||||
} else {
|
||||
callback = utils.createPromiseCallback();
|
||||
}
|
||||
var callbackPromise = callback.promise;
|
||||
const callbackPromise = callback.promise;
|
||||
|
||||
if (findMethodNames.includes(remoteMethod.name)) {
|
||||
callback = proxy404toNull(callback);
|
||||
|
@ -131,7 +131,7 @@ function createProxyMethod(Model, remotes, remoteMethod) {
|
|||
if (remoteMethod.isStatic) {
|
||||
remotes.invoke(remoteMethod.stringName, args, callback);
|
||||
} else {
|
||||
var ctorArgs = [this.id];
|
||||
const ctorArgs = [this.id];
|
||||
remotes.invoke(remoteMethod.stringName, ctorArgs, args, callback);
|
||||
}
|
||||
|
||||
|
|
14
package.json
14
package.json
|
@ -12,10 +12,11 @@
|
|||
"scripts": {
|
||||
"test": "grunt",
|
||||
"posttest": "npm run lint",
|
||||
"lint": "eslint ."
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"node": ">=8"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -32,20 +33,21 @@
|
|||
"homepage": "http://loopback.io",
|
||||
"dependencies": {
|
||||
"loopback-datasource-juggler": "^3.0.0",
|
||||
"strong-remoting": "^3.0.0"
|
||||
"strong-remoting": "^3.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assert": "^1.4.1",
|
||||
"bluebird": "^3.5.1",
|
||||
"eslint": "^6.5.1",
|
||||
"eslint-config-loopback": "^13.1.0",
|
||||
"grunt": "^1.0.3",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"eslint": "^5.4.0",
|
||||
"eslint-config-loopback": "^11.0.0",
|
||||
"loopback": "^3.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"sinon": "^6.0.0",
|
||||
"strong-task-emitter": "^0.0.8"
|
||||
},
|
||||
"optionalDependencies": {}
|
||||
"optionalDependencies": {},
|
||||
"author": "IBM Corp."
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright IBM Corp. 2016,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2016,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
'use strict';
|
||||
|
||||
var extend = require('util')._extend;
|
||||
var loopback = require('loopback');
|
||||
var remoteConnector = require('..');
|
||||
const extend = require('util')._extend;
|
||||
const loopback = require('loopback');
|
||||
const remoteConnector = require('..');
|
||||
|
||||
exports.createMemoryDataSource = createMemoryDataSource;
|
||||
exports.createRemoteDataSource = createRemoteDataSource;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2016,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2016,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2018. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2018,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
@ -37,7 +37,7 @@ describe('Models Define Type Tests', function() {
|
|||
clientApp.model(RemoteModel, {dataSource: remoteDs});
|
||||
|
||||
sinon.assert.calledOnce(defineObjectTypeSpy.withArgs(
|
||||
RemoteModel.modelName
|
||||
RemoteModel.modelName,
|
||||
));
|
||||
});
|
||||
|
||||
|
@ -66,10 +66,10 @@ describe('Models Define Type Tests', function() {
|
|||
clientApp.model(RemoteModel, {dataSource: remoteDs});
|
||||
|
||||
sinon.assert.calledOnce(defineObjectTypeSpy.withArgs(
|
||||
RemoteModel.modelName
|
||||
RemoteModel.modelName,
|
||||
));
|
||||
sinon.assert.calledOnce(defineObjectTypeSpy.withArgs(
|
||||
ChildModel.modelName
|
||||
ChildModel.modelName,
|
||||
));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2016,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2016,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2014,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2014,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright IBM Corp. 2016,2017. All Rights Reserved.
|
||||
// Copyright IBM Corp. 2016,2019. All Rights Reserved.
|
||||
// Node module: loopback-connector-remote
|
||||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
@ -200,6 +200,29 @@ describe('Remote model tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Model.exists(id, callback)', function() {
|
||||
it('should return true when the model with the given id exists',
|
||||
function(done) {
|
||||
ServerModel.create({first: 'max'}, function(err, user) {
|
||||
if (err) return done(err);
|
||||
ClientModel.exists(user.id, function(err, exist) {
|
||||
if (err) return done(err);
|
||||
assert.equal(exist, true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false when there is no model with the given id',
|
||||
function(done) {
|
||||
ClientModel.exists('user-id-does-not-exist', function(err, exist) {
|
||||
if (err) return done(err);
|
||||
assert.equal(exist, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Model.findById(id, callback)', function() {
|
||||
it('should return null when an instance does not exist',
|
||||
function(done) {
|
||||
|
@ -350,4 +373,17 @@ describe('Remote model tests', function() {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('Model.updateAll([where], [data])', () => {
|
||||
it('returns the count of updated instances in data source', async () => {
|
||||
await ServerModel.create({first: 'baby', age: 1});
|
||||
await ServerModel.create({first: 'grandma', age: 80});
|
||||
|
||||
const result = await ClientModel.updateAll(
|
||||
{age: {lt: 6}},
|
||||
{last: 'young'},
|
||||
);
|
||||
assert.deepEqual(result, {count: 1});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue