# ol-mongoose-random

> Plugin for mongoose to fetch random documents

Latest version **0.0.4** (published 2016-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ol-mongoose-random
pnpm add ol-mongoose-random
yarn add ol-mongoose-random
bun add ol-mongoose-random
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2016-08-17 |
| First published | 2016-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | olsynt |
| Maintainers | olsynt |
| Keywords | mongoose |

## Links

- npm: https://www.npmjs.com/package/ol-mongoose-random
- Repository: https://github.com/olsynt/ol-mongoose-random
- Homepage: https://github.com/olsynt/ol-mongoose-random#readme
- Issues: https://github.com/olsynt/ol-mongoose-random/issues
- npm.io page: https://npm.io/package/ol-mongoose-random

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.14.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.0.4 (latest) — 2016-08-17
- 0.0.3 — 2016-08-03
- 0.0.2 — 2016-08-02
- 0.0.1 — 2016-08-02

## README

# Installation
`npm install ol-mongoose-random --save` 

# Usage
```javascript
var mongoose = require('mongoose');
var random = require('ol-mongoose-random');
var Schema = new mongoose.Schema({ /* ... */ });
Schema.plugin(random);

//Get one random document
Schema.randomInit().one().exec().then(function(doc){
    console.log(doc)
})

//Get {{limit}} number of docs
var filter = { tags: { $in: ['bug', 'wontfix'] } };
var conditions = { username: 1, details: 0 };
var options = { skip: 10, limit: 10 }
Schema
.randomInit()
.conditions(conditions)
.fields(filter)
.options(options)
.exec().then(function(collection){
    console.log(collection)
})
```
## Inspired by: [mongoose-random](https://github.com/matomesc/mongoose-random) 

## License

The MIT License (MIT)

Copyright (c) 2013 Mihai Tomescu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

---
_Source: https://npm.io/package/ol-mongoose-random · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
