How to use the warehouse.Schema.Types function in warehouse

To help you get started, we’ve selected a few warehouse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hexojs / hexo / lib / models / post_asset.js View on Github external
module.exports = ctx => {
  const PostAsset = new Schema({
    _id: {type: String, required: true},
    slug: {type: String, required: true},
    modified: {type: Boolean, default: true},
    post: {type: Schema.Types.CUID, ref: 'Post'},
    renderable: {type: Boolean, default: true}
  });

  PostAsset.virtual('path').get(function() {
    const Post = ctx.model('Post');
    const post = Post.findById(this.post);
    if (!post) return;

    // PostAsset.path is file path relative to `public_dir`
    // no need to urlescape, #1562
    // strip /\.html?$/ extensions on permalink, #2134
    return pathFn.join(_.replace(post.path, /\.html?$/, ''), this.slug);
  });

  PostAsset.virtual('source').get(function() {
    return pathFn.join(ctx.base_dir, this._id);
github hexojs / hexo / lib / models / post_category.js View on Github external
module.exports = ctx => {
  const PostCategory = new Schema({
    post_id: {type: Schema.Types.CUID, ref: 'Post'},
    category_id: {type: Schema.Types.CUID, ref: 'Category'}
  });

  return PostCategory;
};
github hexojs / hexo / lib / models / category.js View on Github external
module.exports = ctx => {
  const Category = new Schema({
    name: {type: String, required: true},
    parent: {type: Schema.Types.CUID, ref: 'Category'}
  });

  Category.virtual('slug').get(function() {
    let name = this.name;

    if (!name) return;

    let str = '';

    if (this.parent) {
      const parent = ctx.model('Category').findById(this.parent);
      str += `${parent.slug}/`;
    }

    const map = ctx.config.category_map || {};
github hexojs / hexo / lib / models / post_tag.js View on Github external
module.exports = ctx => {
  const PostTag = new Schema({
    post_id: {type: Schema.Types.CUID, ref: 'Post'},
    tag_id: {type: Schema.Types.CUID, ref: 'Tag'}
  });

  return PostTag;
};
github hexojs / hexo / lib / models / post_tag.js View on Github external
module.exports = ctx => {
  const PostTag = new Schema({
    post_id: {type: Schema.Types.CUID, ref: 'Post'},
    tag_id: {type: Schema.Types.CUID, ref: 'Tag'}
  });

  return PostTag;
};
github hexojs / hexo / lib / models / post_category.js View on Github external
module.exports = ctx => {
  const PostCategory = new Schema({
    post_id: {type: Schema.Types.CUID, ref: 'Post'},
    category_id: {type: Schema.Types.CUID, ref: 'Category'}
  });

  return PostCategory;
};