keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

Open

#3 187 ouverte le 21 juil. 2016

Voir sur GitHub
 (8 commentaires) (0 réactions) (0 assignés)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

Guide contributeur