From 3f3d32a556b13980b8304d42c8bd8d38d29e6581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 1 Sep 2016 11:54:34 +0200 Subject: [PATCH 1/2] lib: use strict, fix whitespaces --- lib/relations.js | 18 ++++++++++-------- lib/remote-connector.js | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/relations.js b/lib/relations.js index 3f4a67a..f0bbc69 100644 --- a/lib/relations.js +++ b/lib/relations.js @@ -3,6 +3,8 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +'use strict'; + /*! * Dependencies */ @@ -39,25 +41,25 @@ function RelationMixin() { * * ```js * Book.create(function(err, book) { - * + * * // Create a chapter instance ready to be saved in the data source. * var chapter = book.chapters.build({name: 'Chapter 1'}); - * + * * // Save the new chapter * chapter.save(); - * + * * // 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. * book.chapters.create({name: 'Chapter 2'}, function(err, savedChapter) { * // this callback is optional * }); - * - * // Query chapters for the book + * + * // Query chapters for the book * book.chapters(function(err, chapters) { - * // all chapters with bookId = book.id + * // all chapters with bookId = book.id * console.log(chapters); * }); - * + * * book.chapters({where: {name: 'test'}, function(err, chapters) { * // All chapters with bookId = book.id and name = 'test' * console.log(chapters); @@ -231,4 +233,4 @@ function defineRelationProperty(modelClass, def) { return scope; } }); -} \ No newline at end of file +} diff --git a/lib/remote-connector.js b/lib/remote-connector.js index e27ca10..b4e16a3 100644 --- a/lib/remote-connector.js +++ b/lib/remote-connector.js @@ -3,6 +3,8 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT +'use strict'; + /** * Dependencies. */ From e047c56e4134000b59137bf81852689c67d71998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 1 Sep 2016 11:56:33 +0200 Subject: [PATCH 2/2] Update to juggler@3 and remoting@3 --- package.json | 10 ++++++---- test/helper.js | 4 +++- test/remote-connector.test.js | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 92638b2..1b37d87 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "name": "loopback-connector-remote", "version": "2.0.0-alpha.1", - "pubishConfig": { "tag": "next" }, + "pubishConfig": { + "tag": "next" + }, "description": "Remote REST API connector for Loopback", "main": "index.js", "keywords": [ @@ -27,8 +29,8 @@ }, "homepage": "http://loopback.io", "dependencies": { - "loopback-datasource-juggler": "^2.8.0", - "strong-remoting": "^2.3.0" + "loopback-datasource-juggler": "^3.0.0-alpha.7", + "strong-remoting": "^3.0.0-alpha.5" }, "devDependencies": { "assert": "^1.1.2", @@ -37,7 +39,7 @@ "grunt-cli": "^0.1.13", "grunt-contrib-jshint": "~0.10.0", "grunt-mocha-test": "^0.11.0", - "loopback": "^2.2.0", + "loopback": "^3.0.0-alpha.3", "mocha": "~1.21.4", "strong-task-emitter": "0.0.5" }, diff --git a/test/helper.js b/test/helper.js index e1ee625..962ca8f 100644 --- a/test/helper.js +++ b/test/helper.js @@ -5,6 +5,7 @@ 'use strict'; +var extend = require('util')._extend; var loopback = require('loopback'); var remoteConnector = require('..'); @@ -48,8 +49,9 @@ function createRemoteDataSource(remoteApp) { * app. */ function createModel(options) { + var modelOptions = extend({ forceId: false }, options.options); var Model = loopback.PersistedModel.extend(options.parent, options.properties, - options.options); + modelOptions); if (options.app) options.app.model(Model); if (options.datasource) Model.attachTo(options.datasource); return Model; diff --git a/test/remote-connector.test.js b/test/remote-connector.test.js index 7b928c9..ba0acdd 100644 --- a/test/remote-connector.test.js +++ b/test/remote-connector.test.js @@ -60,6 +60,7 @@ describe('RemoteConnector', function() { it('should support aliases', function(done) { var calledServerUpsert = false; + ctx.ServerModel.patchOrCreate = ctx.ServerModel.upsert = function(id, cb) { calledServerUpsert = true; cb();