Skip to content

Commit d7616dd

Browse files
committed
Fixed SchemaInstance.$clean().
1 parent 045bb6f commit d7616dd

1 file changed

Lines changed: 9 additions & 28 deletions

File tree

builders.js

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ SchemaBuilderEntity.prototype.operation = function(name, model, helper, callback
18901890

18911891
/**
18921892
* Clean model (remove state of all schemas in model).
1893-
* @param {Object} m
1893+
* @param {Object} m Model.
18941894
* @param {Boolean} isCopied Internal argument.
18951895
* @return {Object}
18961896
*/
@@ -1910,46 +1910,27 @@ SchemaBuilderEntity.prototype.clean = function(m, isCopied) {
19101910
delete model.$schema;
19111911

19121912
if (model.$$async) {
1913-
delete model['$$result'];
1914-
delete model['$$async'];
1915-
delete model['$callback'];
1913+
delete model.$$result;
1914+
delete model.$$async;
1915+
delete model.$callback;
19161916
}
19171917

1918-
/*
1919-
@TODO: works but stays for the testing
19201918
var self = this;
19211919
for (var key in model) {
1922-
1923-
if (key === '$schema')
1924-
continue;
1925-
19261920
var value = model[key];
1927-
1928-
if (!value)
1929-
continue;
1930-
1931-
if (typeof(value) !== OBJECT)
1932-
continue;
1933-
19341921
if (value instanceof Array) {
19351922
for (var j = 0, sublength = value.length; j < sublength; j++) {
1936-
19371923
var item = value[j];
1938-
if (item === null)
1939-
continue;
1940-
1941-
if (typeof(item) !== OBJECT)
1942-
continue;
1943-
1944-
value[j] = self.clean(item, true);
1924+
if (item instanceof SchemaInstance)
1925+
value[j] = self.clean(item, true);
19451926
}
1946-
19471927
continue;
19481928
}
19491929

1950-
model[key] = self.clean(value, true);
1930+
if (value instanceof SchemaInstance)
1931+
model[key] = self.clean(value, true);
19511932
}
1952-
*/
1933+
19531934
return model;
19541935
};
19551936

0 commit comments

Comments
 (0)