# mongoose-plugin-tags

> Mongoose.js plugin to automatically generate tags from a document field.

Latest version **1.2.2** (published 2015-05-08) · Apache 2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mongoose-plugin-tags
pnpm add mongoose-plugin-tags
yarn add mongoose-plugin-tags
bun add mongoose-plugin-tags
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2015-05-08 |
| First published | 2015-05-07 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jason Cust |
| Maintainers | centralping, jasoncust |
| Keywords | mongoose, plugin, tags |

## Links

- npm: https://www.npmjs.com/package/mongoose-plugin-tags
- Repository: https://github.com/CentralPing/mongoose-plugin-tags
- Issues: https://github.com/CentralPing/mongoose-plugin-tags/issues
- npm.io page: https://npm.io/package/mongoose-plugin-tags

## Dependencies (1)

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

## 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

- 1.2.2 (latest) — 2015-05-08
- 1.2.1 — 2015-05-07

## README

mongoose-plugin-tags
====================

[ ![Codeship Status for CentralPing/mongoose-plugin-tags](https://codeship.com/projects/39caf290-4b42-0132-6abf-22e4e23acdc5/status)](https://codeship.com/projects/46704)
[ ![Code Climate for CentralPing/mongoose-plugin-tags](https://codeclimate.com/github/CentralPing/mongoose-plugin-tags/badges/gpa.svg)](https://codeclimate.com/github/CentralPing/mongoose-plugin-tags)
[ ![Dependency Status for CentralPing/mongoose-plugin-tags](https://david-dm.org/CentralPing/mongoose-plugin-tags.svg)](https://david-dm.org/CentralPing/mongoose-plugin-tags)

A [mongoose.js](https://github.com/LearnBoost/mongoose/) plugin to automatically generate tags from a document path.

*Note: tagging updates occur when document is saved.*

## Installation

`npm i --save mongoose-plugin-tags`

## API Reference
**Example**  
```js
var tagsPlugin = require('mongoose-plugin-tags');
var schema = Schema({...});
schema.plugin(tagsPlugin[, OPTIONS]);
```
<a name="module_mongoose-plugin-tags..options"></a>
### mongoose-plugin-tags~options
**Kind**: inner property of <code>[mongoose-plugin-tags](#module_mongoose-plugin-tags)</code>  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options] | <code>object</code> |  |  |
| options.path | <code>string</code> | <code>&quot;tags&quot;</code> | the path to create the propterty for storing tags. |
| options.optionKey | <code>string</code> | <code>&quot;tags&quot;</code> | the path options key to mark paths for inclusion in tagging. |
| options.options | <code>object</code> |  | property options to set (`type` will always be an `Array` of `String`). `(e.g. {select: false})` |
| options.match | <code>string</code> | <code>&quot;/[#＃][a-z_0-9]+/g&quot;</code> | the regular expression to match tags. |
| options.map | <code>string</code> | <code>&quot;function&quot;</code> | the function to strip tag indicators (e.g. '#'). Defaults to stripping the first character from a tag. |


## Examples

### With A Single Field
```js
var tagsPlugin = require('mongoose-plugin-tags');
var schema = Schema({
  foo: {
    type: String,
    tags: true // indicates that foo should be included in tagging
  },
  bar: {type: String} // will not be included
});
schema.plugin(tagsPlugin);

var Foo = mongoose.model('Foo', schema);
var foo = Foo(); // foo.tags --> []
foo.foo = 'I just leanered what a hashtag is #BehindTheTimes'; // foo.tags --> []
foo.save(); // foo.tags --> ['BehindTheTimes']
```

### With Mulitple Fields
```js
var tagsPlugin = require('mongoose-plugin-tags');
var schema = Schema({
  foo: {
    type: String,
    tags: true // indicates that foo should be included in tagging
  },
  bar: {
    type: String,
    tags: true // indicates that bar should be included in tagging
  }
});
schema.plugin(tagsPlugin);

var Foo = mongoose.model('Foo', schema);
var foo = Foo(); // foo.tags --> []
foo.foo = 'You know what grinds my gears? #rant'; // foo.tags --> []
foo.bar = '#People #who #use #hashtags #like #this'; // foo.tags --> []
foo.save(); // foo.tags --> ['rant', 'people', 'who', 'use', 'hashtags', 'like', 'this']
```

# License

Apache 2.0

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