const mongoose = require('mongoose');

const ProductSchema = new mongoose.Schema(
    _id: mongoose.Schema.Types.ObjectId,
    isComplete: { type: Boolean },
    isActive: { type: Boolean },
    friendlyName: { type: String, index: true },//This is the important bit +
    subscription: {
      _id: false,
      type: mongoose.Schema.Types.ObjectId,
      ref: 'Subscription',

    productTypeId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: 'ProductType',
      required: true,

    columns: { type: Array, columnName: String, value: String },
  { timestamps: true }

ProductSchema.index({ friendlyName: 1 });//This is also important bit

const Product = mongoose.model('Product', ProductSchema);

module.exports = Product;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter