Merge pull request #55 from strongloop/feature/loopback-3x

[SEMVER-MAJOR] Update to juggler@3 and remoting@3
This commit is contained in:
Miroslav Bajtoš 2016-09-01 13:07:33 +02:00 committed by GitHub
commit 90cbf650b0
5 changed files with 22 additions and 13 deletions

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
/*! /*!
* Dependencies * Dependencies
*/ */
@ -39,25 +41,25 @@ function RelationMixin() {
* *
* ```js * ```js
* Book.create(function(err, book) { * Book.create(function(err, book) {
* *
* // Create a chapter instance ready to be saved in the data source. * // Create a chapter instance ready to be saved in the data source.
* var chapter = book.chapters.build({name: 'Chapter 1'}); * var chapter = book.chapters.build({name: 'Chapter 1'});
* *
* // Save the new chapter * // Save the new chapter
* chapter.save(); * chapter.save();
* *
* // you can also call the Chapter.create method with the `chapters` property * // you can also call the Chapter.create method with the `chapters` property
* // which will build a chapter instance and save the it in the data source. * // which will build a chapter instance and save the it in the data source.
* book.chapters.create({name: 'Chapter 2'}, function(err, savedChapter) { * book.chapters.create({name: 'Chapter 2'}, function(err, savedChapter) {
* // this callback is optional * // this callback is optional
* }); * });
* *
* // Query chapters for the book * // Query chapters for the book
* book.chapters(function(err, chapters) { * book.chapters(function(err, chapters) {
* // all chapters with bookId = book.id * // all chapters with bookId = book.id
* console.log(chapters); * console.log(chapters);
* }); * });
* *
* book.chapters({where: {name: 'test'}, function(err, chapters) { * book.chapters({where: {name: 'test'}, function(err, chapters) {
* // All chapters with bookId = book.id and name = 'test' * // All chapters with bookId = book.id and name = 'test'
* console.log(chapters); * console.log(chapters);
@ -231,4 +233,4 @@ function defineRelationProperty(modelClass, def) {
return scope; return scope;
} }
}); });
} }

View File

@ -3,6 +3,8 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict';
/** /**
* Dependencies. * Dependencies.
*/ */

View File

@ -1,7 +1,9 @@
{ {
"name": "loopback-connector-remote", "name": "loopback-connector-remote",
"version": "2.0.0-alpha.1", "version": "2.0.0-alpha.1",
"pubishConfig": { "tag": "next" }, "pubishConfig": {
"tag": "next"
},
"description": "Remote REST API connector for Loopback", "description": "Remote REST API connector for Loopback",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
@ -27,8 +29,8 @@
}, },
"homepage": "http://loopback.io", "homepage": "http://loopback.io",
"dependencies": { "dependencies": {
"loopback-datasource-juggler": "^2.8.0", "loopback-datasource-juggler": "^3.0.0-alpha.7",
"strong-remoting": "^2.3.0" "strong-remoting": "^3.0.0-alpha.5"
}, },
"devDependencies": { "devDependencies": {
"assert": "^1.1.2", "assert": "^1.1.2",
@ -37,7 +39,7 @@
"grunt-cli": "^0.1.13", "grunt-cli": "^0.1.13",
"grunt-contrib-jshint": "~0.10.0", "grunt-contrib-jshint": "~0.10.0",
"grunt-mocha-test": "^0.11.0", "grunt-mocha-test": "^0.11.0",
"loopback": "^2.2.0", "loopback": "^3.0.0-alpha.3",
"mocha": "~1.21.4", "mocha": "~1.21.4",
"strong-task-emitter": "0.0.5" "strong-task-emitter": "0.0.5"
}, },

View File

@ -5,6 +5,7 @@
'use strict'; 'use strict';
var extend = require('util')._extend;
var loopback = require('loopback'); var loopback = require('loopback');
var remoteConnector = require('..'); var remoteConnector = require('..');
@ -48,8 +49,9 @@ function createRemoteDataSource(remoteApp) {
* app. * app.
*/ */
function createModel(options) { function createModel(options) {
var modelOptions = extend({ forceId: false }, options.options);
var Model = loopback.PersistedModel.extend(options.parent, options.properties, var Model = loopback.PersistedModel.extend(options.parent, options.properties,
options.options); modelOptions);
if (options.app) options.app.model(Model); if (options.app) options.app.model(Model);
if (options.datasource) Model.attachTo(options.datasource); if (options.datasource) Model.attachTo(options.datasource);
return Model; return Model;

View File

@ -60,6 +60,7 @@ describe('RemoteConnector', function() {
it('should support aliases', function(done) { it('should support aliases', function(done) {
var calledServerUpsert = false; var calledServerUpsert = false;
ctx.ServerModel.patchOrCreate =
ctx.ServerModel.upsert = function(id, cb) { ctx.ServerModel.upsert = function(id, cb) {
calledServerUpsert = true; calledServerUpsert = true;
cb(); cb();