# mongoose-gravatar

> Mongoose plugin for generating gravatar.com urls

Latest version **0.3.0** (published 2014-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install mongoose-gravatar
pnpm add mongoose-gravatar
yarn add mongoose-gravatar
bun add mongoose-gravatar
```

## 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.3.0 |
| Published | 2014-11-14 |
| First published | 2013-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Cristian Douce |
| Maintainers | cristiandouce |
| Keywords | gravatar, mongoose, avatar |

## Links

- npm: https://www.npmjs.com/package/mongoose-gravatar
- Repository: git@github.com:cristiandouce/mongoose-gravatar
- Homepage: https://github.com/cristiandouce/mongoose-gravatar
- Issues: https://github.com/cristiandouce/mongoose-gravatar/issues
- npm.io page: https://npm.io/package/mongoose-gravatar

## 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.3.0 (latest) — 2014-11-14
- 0.2.1 — 2014-01-08
- 0.2.0 — 2014-01-08
- 0.1.0 — 2013-12-27
- 0.0.1 — 2013-12-27

## README

# mongoose-gravatar

  Mongoose plugin to dynamically generate gravatar urls.

  [![Build Status](https://travis-ci.org/cristiandouce/mongoose-gravatar.png?branch=master)](https://travis-ci.org/cristiandouce/mongoose-gravatar)

## Installation

```
  $ npm install mongoose-gravatar
```

## Usage example

Setup

```js
var gravatar = require('mongoose-gravatar');
var UserSchema = new Schema({ email: String });

// Extend User's Schema with gravatar plugin
UserSchema.plugin(gravatar);

// or... provide some default options for plugin
UserSchema.plugin(gravatar, { secure: true, default: "retro", size: 245 });

// or... custom schema property
UserSchema = new Schema({ primaryEmail: String });
UserSchema.plugin(gravatar, { property: 'primaryEmail' });

// ...
```

Retrieving Gravatar from User Model

```js
var author = new User({ email: 'jorge@ups.com' });

// retrieves a normal gravatar url
author.gravatar()
// out: 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8'

// retrieves a secure (https) gravatar url
author.gravatar({ secure: true })
// out: 'https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8'

// sets size to 150px width and height
author.gravatar({ size: 150 });
// out: 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=150'

// With provided options at plugin level...
author.gravatar()
// out: https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?d=retro&s=245
```

## Plugin specific options
* `property`: Schema property, optional, defaults to `email`

## API options list
The following are the list of options allowed for `.gravatar()` model method.
* `secure`: Compiles a secure url for gravatars. Check `gravatar.com` [docs](http://en.gravatar.com/site/implement/images/#secure-images) for more info.
* `email`: Returns a gravatar url for a different email than the model's.
* `size`: Determines the size of the image delivered by `gravatar.com`. Check `gravatar.com` [docs](http://en.gravatar.com/site/implement/images/#size) for more info.
* `default`: Sets a default image when email has no avatar registered at `gravatar.com`. Check `gravatar.com` [docs](http://en.gravatar.com/site/implement/images/#default-image) for more info.
* `forcedefault`: Forces default image. Check `gravatar.com` [docs](http://en.gravatar.com/site/implement/images/#force-default) for more info.
* `rating`: Sets self-rated image policy. Check `gravatar.com` [docs](http://en.gravatar.com/site/implement/images/#rating) for more info.


## Test

```
  $ npm install --dev
  $ make test
```
## License

  MIT

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