Allow toObject() to accept an 'options' argument
This commit is contained in:
parent
4aa51e9956
commit
90163ba709
|
@ -418,6 +418,12 @@ ModelBaseClass.toString = function() {
|
|||
* @returns {Object} returns Plain JSON object
|
||||
*/
|
||||
ModelBaseClass.prototype.toObject = function(onlySchema, removeHidden, removeProtected) {
|
||||
if (typeof onlySchema === 'object' && onlySchema != null) {
|
||||
var options = onlySchema;
|
||||
onlySchema = options.onlySchema;
|
||||
removeHidden = options.removeHidden;
|
||||
removeProtected = options.removeProtected;
|
||||
}
|
||||
if (onlySchema === undefined) {
|
||||
onlySchema = true;
|
||||
}
|
||||
|
|
|
@ -133,8 +133,8 @@ describe('ModelBuilder', function() {
|
|||
|
||||
// Predefined property bio should be kept
|
||||
user.toObject().should.have.property('bio', 'me');
|
||||
user.toObject(true).should.have.property('bio', 'me');
|
||||
user.toObject(false).should.have.property('bio', 'me');
|
||||
user.toObject({onlySchema: true}).should.have.property('bio', 'me');
|
||||
user.toObject({onlySchema: false}).should.have.property('bio', 'me');
|
||||
|
||||
done(null, User);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue