0.5.0 • Published 2 years ago

@lykmapipo/mongoose-taggable v0.5.0

Weekly downloads
362
License
MIT
Repository
github
Last release
2 years ago

mongoose-taggable

Build Status Dependencies Status Coverage Status GitHub License

Commitizen Friendly code style: prettier Code Style npm version

mongoose plugin to add tags and taggable behaviour.

Requirements

Install

$ npm install --save mongoose @lykmapipo/mongoose-taggable

Usage

import mongoose from 'mongoose';
import taggable from '@lykmapipo/mongoose-taggable';

const RepoSchema = new Schema({ name: { type: String, taggable: true } });
RepoSchema.plugin(taggable);
const Repo = mongoose.model('Repo', RepoSchema);

const repo = new Repo({ name: 'any-js'});
repo.tag();
repo.tag('js', 'nodejs', 'express', 'mongoose');
repo.untag('angular');

API

taggable(schema: Schema, [options: Object])

A taggable schema plugin. Once applied to a schema will allow to compute tags from taggable schema field and and tag and untag instance methods

options: Object

  • blacklist: String | String[] - List of word(s) not allowed to be used for tagging.
  • fresh: Boolean - Whether to recompute fresh tags. Default to false.
  • hook: String - When to run tagging hook. Default to pre validate.

Example

const RepoSchema = new Schema({ name: { type: String, taggable: true } });
RepoSchema.plugin(taggable);
const Repo = mongoose.model('Repo', RepoSchema);

const RepoSchema = new Schema({ name: { type: String, taggable: true } });
RepoSchema.plugin(taggable, { blacklist: ['unknown'] });
const Repo = mongoose.model('Repo', RepoSchema);

tag(...tag: String)

Tag a model instance with provided tags

Example:

user.tag('js', 'dev', 'conf');

untag(...tag: String)

Untag a model instance to not include provided tags

Example:

user.untag('conf');

Testing

  • Clone this repository

  • Install all development dependencies

$ npm install
  • Then run test
$ npm test

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

Licence

The MIT License (MIT)

Copyright (c) lykmapipo & Contributors

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.

0.5.0

2 years ago

0.4.35

4 years ago

0.4.34

4 years ago

0.4.33

4 years ago

0.4.32

4 years ago

0.4.31

4 years ago

0.4.30

4 years ago

0.4.29

4 years ago

0.4.28

4 years ago

0.4.27

4 years ago

0.4.26

4 years ago

0.4.25

4 years ago

0.4.24

4 years ago

0.4.23

4 years ago

0.4.22

4 years ago

0.4.21

4 years ago

0.4.20

4 years ago

0.4.19

4 years ago

0.4.18

4 years ago

0.4.17

4 years ago

0.4.16

4 years ago

0.4.15

4 years ago

0.4.14

4 years ago

0.4.13

4 years ago

0.4.12

4 years ago

0.4.11

5 years ago

0.4.10

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago