我有rethinkdb实例,由nodejs客户端使用。
rethinkdb
.db(p.rdb_database)
.table(p.table)
.orderBy({index: 'uidAndDate'})
.filter({})
.run(rethinkdbConnection, function (error, cursor) {...})有没有办法对.run函数进行猴子补丁?我希望像这样监视rethinkdb客户端-添加before函数。
rethinkdb
.db(p.rdb_database)
.table(p.table)
.orderBy({index: 'uidAndDate'})
.filter({})
.before(function(error, query, result, next){
console.log('query: ',query);
console.log('result: ',result);
next(error);
})
.run(rethinkdbConnection, function (error, cursor) {...})发布于 2014-10-09 21:42:51
你可以用这样的东西来修补它
TermBase = r.expr(1).constructor.__super__.constructor.__super__
TermBase.run_copy = TermBase.run;
Termbase.run = function(callback) {
console.log("query", this.toString());
this.run_copy(function(error, result) {
if (error) {
console.log("error", error)
}
else {
console.log("result", result)
}
callback(error, result)
})
})但这有点下流。
https://stackoverflow.com/questions/26287983
复制相似问题