0.6.0 • Published 4 years ago

@pozible/mongoose-yas v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

npm (scoped) Build Status

mongoose-yas

Mongoose Yet Another Slug, follows the same idea to create a slug based on meteor-friendly-slugs. This package uses same API and data structure:

{
  slug: 'your-slug', // Actual slug can be used in your app
  friendSlugs: { // Should be used by the plugin only
    slug: {
      base: 'your-slug', // Slug result from `slugFrom` without index
      index: 0, // Index of `slug` that is in the same `base`
    }
  }
}

Usage

const mongoose = require('mongoose')
const mongooseyas = require('@pozible/mongoose-yas')

const Schema = new mongoose.Schema({
  title: {type: String},
  friendlySlugs: Object,
  publisher: {type: String},
  slug: {type: String, slugFrom: 'title', distinctUpTo: ['publisher']},
})

Schema.plugin(mongooseyas)

const Book = mongoose.model('Book', Schema)

Book.create({
  title: 'i ♥ unicode',
  publisher: 'PUB_1'
}, function(book) {
  console.log(book.slug)
})

Important: slug and friendlySlugs are required attributes that must be declared in schema.

Limitations

  • Fixed slug and friendlySlugs attributes that must be declared in schema to make the plugin works.
  • and few other more.
0.6.0

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago