Error if user already exists, clean user

This commit is contained in:
Thomas Forgione
2017-09-29 10:30:19 +02:00
parent dff2c4bbb8
commit aa88b397d8
6 changed files with 35 additions and 6 deletions

View File

@@ -245,6 +245,25 @@ module.exports.createClass = function(model) {
}
}
ret.prototype.toJSON = function() {
let json = {};
for (let field of model.fields) {
json[field.name] = this[field.name]
}
return json;
}
ret.fromJSON = function(json) {
let result = new ret();
for (let field of model.fields) {
result[field.name] = json[field.name];
}
result._persisted = false;
return result;
}
ret.prototype.save = function(callback = () => {}) {
let fieldsToSave = [];
for (let field of model.fields) {