我想将cachegoose https://www.npmjs.com/package/cachegoose与mongoose 一起使用,但我必须使用TypeScript。如果我只想添加 .cache 选项以便我可以使用下面的内容,我该怎么做?
我不想替换 mongoose index.d.ts 并且我没有时间/知识来为 cachegoose 制作打字文件,我只是想尽可能轻松地添加功能。类似于 Global.d.ts,我可以在其中扩展 mongoose 并添加缓存:any。(类似于如何扩展 Material UI 的托盘)
Record
.find({ some_condition: true })
.cache(30) // The number of seconds to cache the query. Defaults to 60 seconds.
.exec(function(err, records) {
...
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
171 次 |
| 最近记录: |