Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blugavere/mongoose-model-cache
https://github.com/blugavere/mongoose-model-cache
batching cache es6-proxies mongoose performance proxies
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/blugavere/mongoose-model-cache
- Owner: blugavere
- Created: 2018-06-16T23:56:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-22T22:13:54.000Z (over 6 years ago)
- Last Synced: 2024-10-10T10:41:04.163Z (about 1 month ago)
- Topics: batching, cache, es6-proxies, mongoose, performance, proxies
- Language: TypeScript
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![NPM version][npm-image]][npm-url]# Mongoose Model Cache
> Collection level batching and caching for mongoose queries, powered by es6 proxies.
# Usage
```ts
import mongoose from 'mongoose';
import modelCache from 'mongoose-model-cache';// configure a schema somewhere
const schema = new mongoose.Schema({
name: { type: String }
});// register it to mongoose
const Cat = mongoose.model('Cat', schema);const CatCache = modelCache(Cat, {
ttl: 5000 // cache for 5 seconds
});(async () => {
const cats = await CatCache.find();
console.log(cats);
})();// optionally, replace global instance
mongoose.models['Cat'] = CatCache;```
## Supported Methods:
- find
- findOne
- findById
- count[npm-image]: https://badge.fury.io/js/mongoose-model-cache.svg
[npm-url]: https://npmjs.org/package/mongoose-model-cache
[downloads-url]: https://www.npmjs.com/package/mongoose-model-cache
[downloads-image]: https://img.shields.io/npm/dm/mongoose-model-cache.svg?style=flat
[travis-image]: https://travis-ci.com/blugavere/mongoose-model-cache.svg?branch=master
[travis-url]: https://travis-ci.com/blugavere/mongoose-model-cache
[coveralls-image]: https://coveralls.io/repos/blugavere/mongoose-model-cache/badge.svg
[coveralls-url]: https://coveralls.io/r/blugavere/mongoose-model-cache