keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

Open

#3.187 geöffnet am 21. Juli 2016

Auf GitHub ansehen
 (8 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (14.656 Stars) (2.288 Forks)batch import
help wantedneeds input

Beschreibung

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