cachegoose
Advanced tools
Comparing version 3.0.1 to 3.0.2
{ | ||
"name": "cachegoose", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Mongoose caching that actually works.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,5 +66,9 @@ # cachegoose # | ||
That's pretty much it. Just insert `.cache()` into the queries you want to cache, and they will be cached. Works with `select`, `lean`, `sort`, and anything else that will modify the results of a query. | ||
Insert `.cache()` into the queries you want to cache, and they will be cached. Works with `select`, `lean`, `sort`, and anything else that will modify the results of a query. | ||
## Caching populated documents ## | ||
When a document is returned from the cache, cachegoose will [hydrate](http://mongoosejs.com/docs/api.html#model_Model.hydrate) it, which initializes it's virtuals/methods. Hydrating a populated document will discard any populated fields (see [Automattic/mongoose#4727](https://github.com/Automattic/mongoose/issues/4727)). To cache populated documents without losing child documents, you must use `.lean()`, however if you do this you will not be able to use any virtuals/methods (it will be a plain object). | ||
## Test ## | ||
npm test |
26247
74