keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

Open

#3187 opened on Jul 21, 2016

View on GitHub
 (8 comments) (0 reactions) (0 assignees)JavaScript (14,656 stars) (2,288 forks)batch import
help wantedneeds input

Description

I need to write a mongoose plugin. where I need a Request object to find hostname.

module.exports = exports = function(schema, options) {
    schema.add({
        hostname: String
    })

    schema.pre('save', true, function(next, done) {
        this.hostname = req.headers.host; //need request object
        next();
        setTimeout(done, 100);
    });
}

I have raised related question in stackoverflow

Contributor guide