From a3f1cef194894d460de899d77d61b20b30c77125 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Fri, 23 Sep 2016 16:19:14 -0400 Subject: [PATCH 1/3] Update sdk to use loopback 3.x --- apidocs/describe-builtin-models.js | 2 +- package.json | 4 ++-- test.e2e/spec/services.spec.js | 8 ++++---- test.e2e/test-server.js | 26 +++++++++++++++++++------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apidocs/describe-builtin-models.js b/apidocs/describe-builtin-models.js index 1b17115..19a5666 100644 --- a/apidocs/describe-builtin-models.js +++ b/apidocs/describe-builtin-models.js @@ -25,7 +25,7 @@ console.log('Generating API docs for LoopBack built-in models.'); var app = loopback(); -app.dataSource('db', { connector: 'memory', defaultForType: 'db' }); +app.dataSource('db', { connector: 'memory' }); var modelNames = []; for (var key in loopback) { diff --git a/package.json b/package.json index b103f6e..b7a66b4 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "karma-mocha-reporter": "^1.1.5", "karma-phantomjs-launcher": "^1.0.1", "karma-requirejs": "^0.2.1", - "loopback": "^2.0", - "loopback-datasource-juggler": "^2.0", + "loopback": "^3.0", + "loopback-datasource-juggler": "^3.0", "mocha": "~1.18.0", "morgan": "^1.2", "phantomjs-prebuilt": "^2.1.7", diff --git a/test.e2e/spec/services.spec.js b/test.e2e/spec/services.spec.js index b12beaa..04c6d86 100644 --- a/test.e2e/spec/services.spec.js +++ b/test.e2e/spec/services.spec.js @@ -361,7 +361,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { }); }); - it('can create multiple new resources', function() { + it.skip('can create multiple new resources', function() { var arr = MyModel.createMany([ { name: 'one', multi: true }, { name: 'two', multi: true }, @@ -443,7 +443,8 @@ define(['angular', 'given', 'util'], function(angular, given, util) { 'deleteById', 'removeById', 'count', - 'prototype$updateAttributes', + 'prototype$patchAttributes', + 'updateAttributes', ]); }); @@ -854,7 +855,6 @@ define(['angular', 'given', 'util'], function(angular, given, util) { app.models.Product.create({ name: 'p1' }, function(err, prod) { if (err) return cb(err); debug('Created product', prod); - prod.categories.create({ name: 'c1' }, function(err, cat) { if (err) return cb(err); debug('Created category', cat); @@ -966,7 +966,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { }); }); - it('creates multiple related models', function() { + it.skip('creates multiple related models', function() { var cats = Product.categories.createMany( { id: testData.product.id }, [ diff --git a/test.e2e/test-server.js b/test.e2e/test-server.js index 93068b3..6eda86d 100644 --- a/test.e2e/test-server.js +++ b/test.e2e/test-server.js @@ -81,17 +81,29 @@ masterApp.post('/setup', function(req, res, next) { lbApp = loopback(); - lbApp.dataSource('db', { connector: 'memory', defaultForType: 'db' }); - lbApp.dataSource('mail', { connector: 'mail', defaultForType: 'mail' }); + lbApp.dataSource('db', { connector: 'memory' }); + for (var m in initialModels) { + if (initialModels[m].base.modelName == 'PersistedModel') + lbApp.model(initialModels[m], { dataSource: 'db' }); + } for (var m in models) { - models[m].dataSource = 'db'; - var model = initialModels[m]; - lbApp.model(model || m, models[m]); + console.log('custom model of ', m); + var model = null; + var options = models[m].options || {}; + if (initialModels[m]) { + model = initialModels[m]; + lbApp.model(model, extend({ dataSource: 'db' }, options)); + } else { + model = lbApp.registry.createModel( + m, + models[m].properties || {}, + options + ); + lbApp.model(model, { dataSource: 'db' }); + } } - loopback.autoAttach(); - if (enableAuth) lbApp.enableAuth(); From 7855567dc57562b10fc76f2d560cd7d5103ce0bb Mon Sep 17 00:00:00 2001 From: David Cheung Date: Mon, 3 Oct 2016 11:21:36 -0400 Subject: [PATCH 2/3] fixup! Update sdk to use loopback 3.x --- lib/services.template.ejs | 6 ++++++ test.e2e/spec/services.spec.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/services.template.ejs b/lib/services.template.ejs index eaada72..d108178 100644 --- a/lib/services.template.ejs +++ b/lib/services.template.ejs @@ -175,6 +175,12 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && (action.sharedMethod.aliases || []).forEach(function(alias) { var aliasMethod = alias.split('.').join('$'); + // this is to handle strong-remoting does not prepend prototype. + // back into prototype methods + if (action.sharedMethod.isStatic === false) { + aliasMethod = ['prototype', aliasMethod].join('$'); + } + ngdocForMethod(modelName, aliasMethod, action); -%> R[<%-: aliasMethod | q %>] = R[<%-: methodName | q %>]; <% }); // aliases.foreach diff --git a/test.e2e/spec/services.spec.js b/test.e2e/spec/services.spec.js index 04c6d86..a2cefef 100644 --- a/test.e2e/spec/services.spec.js +++ b/test.e2e/spec/services.spec.js @@ -444,7 +444,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { 'removeById', 'count', 'prototype$patchAttributes', - 'updateAttributes', + 'prototype$updateAttributes', ]); }); From 59c29267ac3a032de4fd3b01bea34321ed1b0711 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Tue, 1 Nov 2016 15:02:09 -0400 Subject: [PATCH 3/3] fixup! fixup! Update sdk to use loopback 3.x --- test.e2e/spec/services.spec.js | 4 ++-- test.e2e/test-server.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test.e2e/spec/services.spec.js b/test.e2e/spec/services.spec.js index a2cefef..15ea7f6 100644 --- a/test.e2e/spec/services.spec.js +++ b/test.e2e/spec/services.spec.js @@ -361,7 +361,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { }); }); - it.skip('can create multiple new resources', function() { + it('can create multiple new resources', function() { var arr = MyModel.createMany([ { name: 'one', multi: true }, { name: 'two', multi: true }, @@ -966,7 +966,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { }); }); - it.skip('creates multiple related models', function() { + it('creates multiple related models', function() { var cats = Product.categories.createMany( { id: testData.product.id }, [ diff --git a/test.e2e/test-server.js b/test.e2e/test-server.js index 6eda86d..bd9cf17 100644 --- a/test.e2e/test-server.js +++ b/test.e2e/test-server.js @@ -88,7 +88,6 @@ masterApp.post('/setup', function(req, res, next) { } for (var m in models) { - console.log('custom model of ', m); var model = null; var options = models[m].options || {}; if (initialModels[m]) {