keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

Open

#3.187 aberto em 21 de jul. de 2016

Ver no 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

Guia do colaborador