Compare commits

...

23 Commits

Author SHA1 Message Date
Diana Lau a529986c65
Merge pull request #106 from strongloop/docs/end-of-life
docs: end of life
2021-03-05 19:59:17 -05:00
Miroslav Bajtoš c362bcf930
docs: end of life
LB3 has reached end of life and this connector does not support LB4.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2021-03-03 09:23:27 +01:00
Miroslav Bajtoš 64c88ab382
Merge pull request #105 from strongloop/node14
chore: add Node.js 14 to CI
2020-09-11 11:58:46 +02:00
Diana Lau 4b5ac98379 chore: add Node.js 14 to CI
Signed-off-by: Diana Lau <dhmlau@ca.ibm.com>
2020-09-10 15:15:24 -04:00
Diana Lau 2120e96dbf
Merge pull request #104 from strongloop/dco
chore: switch to DCO
2020-08-31 13:25:21 -04:00
Diana Lau be758fa770 chore: switch to DCO
Signed-off-by: Diana Lau <dhmlau@ca.ibm.com>
2020-08-20 21:22:09 -04:00
Agnes Lin b8fd18e217
Merge pull request #103 from strongloop/copyright
chore: update copyright year
2020-02-10 14:05:41 -05:00
Diana Lau 334b705c69 chore: update copyright year 2020-02-10 13:49:27 -05:00
Nora 4bfa461229
Merge pull request #101 from strongloop/chore/improve-issue-templates
chore: improve issue and PR templates
2019-11-21 09:46:27 -05:00
Nora 4f8a372d2c chore: improve issue and PR templates 2019-11-19 11:25:06 -05:00
Nora 22ee132941
Merge pull request #102 from strongloop/fix-comma-dangle
chore: fix eslint violations
2019-11-19 11:24:39 -05:00
Nora 1975481cb0 chore: fix eslint violations
Fix comma-dangle violations
2019-11-15 21:03:12 -05:00
Miroslav Bajtoš c03161dfe0
Merge pull request #100 from strongloop/fix/loopback-remote-invoke-updateAll
Add a test to verify PersistedModel updateAll
2019-10-07 11:12:09 +02:00
Miroslav Bajtoš 39771be12f
Add a test to verify PersistedModel updateAll
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-10-07 10:49:57 +02:00
Miroslav Bajtoš 4ff55feb24
Merge pull request #99 from strongloop/update-eslint
Update eslint & config to latest
2019-10-04 10:04:32 +02:00
Miroslav Bajtoš 0097580537
Update eslint & config to latest
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-10-03 10:54:13 +02:00
Miroslav Bajtoš 4efca1f052
Merge pull request #95 from angfal/fix/remote_exists
Add tests to check Model.exists() working
2019-08-23 10:27:56 +02:00
Maxim Sharai 2aff46a79a
Add tests to verify Model.exists() is working 2019-08-23 10:16:02 +02:00
Nora 6caf45d39e
Merge pull request #97 from strongloop/add-node-12
Drop support for Node.js 6 and add Node.js 12 to CI
2019-07-25 17:46:11 -04:00
Nora acbe35879b add node 12 to CI 2019-07-25 15:39:50 -04:00
Nora e5e4ba93ef drop support for node 6 2019-07-25 15:39:33 -04:00
Diana Lau 61f031aeb9
Merge pull request #96 from strongloop/copyrights
chore: update copyrights years
2019-05-08 11:47:25 -04:00
Agnes Lin 59f70ab3ce chore: update copyrights years 2019-05-07 13:34:15 -04:00
19 changed files with 231 additions and 228 deletions

View File

@ -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
-->

50
.github/ISSUE_TEMPLATE/Bug_report.md vendored Normal file
View File

@ -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_

View File

@ -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.

27
.github/ISSUE_TEMPLATE/Question.md vendored Normal file
View File

@ -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/
-->

11
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -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.

View File

@ -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)

View File

@ -1,6 +1,7 @@
sudo: false
language: node_js
node_js:
- "6"
- "8"
- "10"
- "12"
- "14"

View File

@ -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

View File

@ -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({

View File

@ -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.

View File

@ -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);
};

View File

@ -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);
}

View File

@ -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."
}

View File

@ -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;

View File

@ -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

View File

@ -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,
));
});
});

View File

@ -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

View File

@ -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

View File

@ -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});
});
});
});