express-promise icon indicating copy to clipboard operation
express-promise copied to clipboard

Added posibility to skip toJSON and then filter objects by user own function

Open semoro opened this issue 9 years ago • 1 comments

When working with Sequelize i created model instance method item.url() and want to use it inside Jade code, also mixed with providing Promise to render method, so i could't use skipTraverse. I had added two optional functions

app.use(require('express-promise')({
    disableJSONify: function (object) {
        return true; //You can add more logic here if you want to select which page would passed without toJSON call
    },
    objectFilter: function (object) {
        if (object && object.model) //Example for Sequelize, will skip object if it was ORM model
            return true;
        return false;
    }
}));

semoro avatar Oct 05 '15 14:10 semoro

Also skipTraverse not working for ORM models....

semoro avatar Oct 05 '15 15:10 semoro