ibird-core
Version:
The core module of ibird.
33 lines (28 loc) • 836 B
JavaScript
;
function remodel(Model) {
find(Model)
findOne(Model)
findById(Model)
}
function find(Model) {
const raw = Model.find
Model.find = async function(conditions, projection, options, callback) {
console.log('进入缓存find')
return raw.call(this, conditions, projection, options, callback)
}
}
function findOne(Model) {
const raw = Model.findOne
Model.findOne = async function(conditions, projection, options, callback) {
console.log('进入缓存findOne')
return raw.call(this, conditions, projection, options, callback)
}
}
function findById(Model) {
const raw = Model.findById
Model.findById = async function(id, projection, options, callback) {
console.log('进入缓存findById')
return raw.call(this, id, projection, options, callback)
}
}
exports.remodel = remodel