Merge pull request #2696 from strongloop/feature/coercion-overhaul
Use strong-remoting's new TypeRegistry
This commit is contained in:
commit
252b6f41c6
|
@ -138,6 +138,9 @@ app.model = function(Model, config) {
|
|||
this.models().push(Model);
|
||||
|
||||
if (isPublic && Model.sharedClass) {
|
||||
this.remotes().defineObjectType(Model.modelName, function(data) {
|
||||
return new Model(data);
|
||||
});
|
||||
this.remotes().addClass(Model.sharedClass);
|
||||
if (Model.settings.trackChanges && Model.Change) {
|
||||
this.remotes().addClass(Model.Change.sharedClass);
|
||||
|
@ -316,8 +319,10 @@ app.enableAuth = function(options) {
|
|||
g.f('Authentication requires model %s to be defined.', m));
|
||||
}
|
||||
|
||||
if (m.dataSource || m.app) return;
|
||||
if (Model.dataSource || Model.app) return;
|
||||
|
||||
// Find descendants of Model that are attached,
|
||||
// for example "Customer" extending "User" model
|
||||
for (var name in appModels) {
|
||||
var candidate = appModels[name];
|
||||
var isSubclass = candidate.prototype instanceof Model;
|
||||
|
|
|
@ -134,11 +134,6 @@ module.exports = function(registry) {
|
|||
remotingOptions
|
||||
);
|
||||
|
||||
// setup a remoting type converter for this model
|
||||
RemoteObjects.convert(typeName, function(val) {
|
||||
return val ? new ModelCtor(val) : val;
|
||||
});
|
||||
|
||||
// support remoting prototype methods
|
||||
ModelCtor.sharedCtor = function(data, id, fn) {
|
||||
var ModelCtor = this;
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
"ejs": "^2.3.1",
|
||||
"express": "^4.14.0",
|
||||
"inflection": "^1.6.0",
|
||||
"loopback-connector-remote": "^2.0.0-alpha.1",
|
||||
"loopback-connector-remote": "^2.0.0-alpha.2",
|
||||
"loopback-datasource-juggler": "^3.0.0-alpha.7",
|
||||
"isemail": "^1.2.0",
|
||||
"loopback-phase": "^1.2.0",
|
||||
|
@ -55,7 +55,7 @@
|
|||
"serve-favicon": "^2.2.0",
|
||||
"stable": "^0.1.5",
|
||||
"strong-globalize": "^2.6.2",
|
||||
"strong-remoting": "^3.0.0-alpha.5",
|
||||
"strong-remoting": "^3.0.0-alpha.6",
|
||||
"uid2": "0.0.3",
|
||||
"underscore.string": "^3.0.3"
|
||||
},
|
||||
|
|
|
@ -656,6 +656,9 @@ describe('relations - integration', function() {
|
|||
|
||||
describe('hasAndBelongsToMany', function() {
|
||||
beforeEach(function defineProductAndCategoryModels() {
|
||||
// Disable "Warning: overriding remoting type product"
|
||||
this.app.remotes()._typeRegistry._options.warnWhenOverridingType = false;
|
||||
|
||||
var product = app.registry.createModel(
|
||||
'product',
|
||||
{ id: 'string', name: 'string' }
|
||||
|
|
|
@ -15,7 +15,10 @@ describe('RemoteConnector', function() {
|
|||
beforeEach: function(done) {
|
||||
var test = this;
|
||||
remoteApp = loopback();
|
||||
remoteApp.set('remoting', { errorHandler: { debug: true, log: false }});
|
||||
remoteApp.set('remoting', {
|
||||
errorHandler: { debug: true, log: false },
|
||||
types: { warnWhenOverridingType: false },
|
||||
});
|
||||
remoteApp.use(loopback.rest());
|
||||
remoteApp.listen(0, function() {
|
||||
test.dataSource = loopback.createDataSource({
|
||||
|
@ -51,6 +54,9 @@ describe('RemoteConnector', function() {
|
|||
beforeEach(function(done) {
|
||||
var test = this;
|
||||
remoteApp = this.remoteApp = loopback();
|
||||
remoteApp.set('remoting', {
|
||||
types: { warnWhenOverridingType: false },
|
||||
});
|
||||
remoteApp.use(loopback.rest());
|
||||
var ServerModel = this.ServerModel = loopback.PersistedModel.extend('TestModel');
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ describe('User', function() {
|
|||
app.enableAuth({ dataSource: 'db' });
|
||||
app.use(loopback.token({ model: AccessToken }));
|
||||
app.use(loopback.rest());
|
||||
app.model(User);
|
||||
|
||||
User.create(validCredentials, function(err, user) {
|
||||
if (err) return done(err);
|
||||
|
|
Loading…
Reference in New Issue