keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

Open

#3187 aperta il 21 lug 2016

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)JavaScript (2288 fork)batch import
help wantedneeds input

Metriche repository

Star
 (14.656 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor