Snippets Collections
<script type="application/ld+json">
{ "@context": "http://schema.org", 
 "@type": "Blog",
 "keywords": "software engineering agile refactoring c# ruby javascript", 
 "url": "https://pauldambra.github.io",
 "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://pauldambra.github.io"
  },
 "author": {
    "@type": "Person",
    "name": "Paul D'Ambra",
    "sameAs": [
        "https://twitter.com/pauldambra",
        "https://github.com/pauldambra",
        "https://plus.google.com/u/0/+PaulDAmbraPlus"
    ]
  }
 }
</script>
// To check which fields are indexed
Product.collection
  .getIndexes({ full: true })
  .then((indexes) => {
    console.log('indexes:', indexes);
  })
  .catch(console.error);

// To check if indexing works
(async () => {
  const result = await Product.find(
    { friendlyName: 'Nice other Name' },
    '_id'
  ).explain('executionStats');
  console.log(result);
})();
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;
star

Wed Dec 28 2022 07:19:34 GMT+0000 (Coordinated Universal Time) https://pauldambra.dev/structured-data-with-jekyll.html

##schema.org #json-ld #jekyll #schema
star

Fri May 21 2021 16:36:01 GMT+0000 (Coordinated Universal Time)

#mongoose #schema #indexing #checkifworks
star

Fri May 21 2021 16:33:23 GMT+0000 (Coordinated Universal Time)

#mongoose #schema #indexing
star

Thu Oct 22 2020 14:19:46 GMT+0000 (Coordinated Universal Time) http://learnmongodbthehardway.com/schema/timeseries/#notes

#mongo #timeseries #schema

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension