Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-plugin-tags

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-plugin-tags

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

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

mongoose-plugin-tags

Codeship Status for CentralPing/mongoose-plugin-tags Code Climate for CentralPing/mongoose-plugin-tags Dependency Status for CentralPing/mongoose-plugin-tags

A mongoose.js 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

var tagsPlugin = require('mongoose-plugin-tags');
var schema = Schema({...});
schema.plugin(tagsPlugin[, OPTIONS]);

mongoose-plugin-tags~options

Kind: inner property of mongoose-plugin-tags

ParamTypeDefaultDescription
[options]object
options.pathstring"tags"the path to create the propterty for storing tags.
options.optionKeystring"tags"the path options key to mark paths for inclusion in tagging.
options.optionsobjectproperty options to set (type will always be an Array of String). (e.g. {select: false})
options.matchstring"/[##][a-z_0-9]+/g"the regular expression to match tags.
options.mapstring"function"the function to strip tag indicators (e.g. '#'). Defaults to stripping the first character from a tag.

Examples

With A Single Field

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

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

Keywords

FAQs

Package last updated on 08 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc