keystonejs/keystone-classic

Provide hostname etc from request to schemaplugins and hooks

開放

#3,187 建立於 2016年7月21日

 (8 則留言) (0 個反應) (0 位負責人)JavaScript (2,288 個分叉)batch import
help wantedneeds input

倉庫指標

星標
 (14,656 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南