diff --git a/CHANGELOG.md b/CHANGELOG.md index a1eba58..fae3c27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.2.0 + +New feature to disable indexing through setting a variable in Meteor settings + ## 3.1.0 Update dependencies (`aldeed:collection2@3.5.0`, `ecmascript` according to Meteor version) diff --git a/README.md b/README.md index 27269ee..35eb419 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,20 @@ You can use the `sparse` option along with the `index` and `unique` options to t All indexes are built in the background so indexing does *not* block other database queries. +## Disabling Indexing + +If you want to disable indexing via collection2 for your app you can set the following variable in your settings: + +```js +{ + "packages": { + "collection2": { + "disableIndexing": true + } + } +} +``` + ## Contributing Anyone is welcome to contribute. Fork, make and test your changes (`meteor test-packages ./`), and then submit a pull request. diff --git a/package/indexing/package.js b/package/indexing/package.js index 9f652eb..79c12cc 100644 --- a/package/indexing/package.js +++ b/package/indexing/package.js @@ -1,7 +1,7 @@ Package.describe({ name: "aldeed:schema-index", summary: "Control some MongoDB indexing with schema options", - version: "3.1.0", + version: "3.2.0", documentation: "../../README.md", git: "https://github.com/aldeed/meteor-schema-index.git", }); diff --git a/package/indexing/server.js b/package/indexing/server.js index fd1d4c6..ac3678a 100644 --- a/package/indexing/server.js +++ b/package/indexing/server.js @@ -4,6 +4,8 @@ import { Meteor } from "meteor/meteor"; import "./common"; Collection2.on("schema.attached", (collection, ss) => { + if (Meteor.settings?.packages?.collection2?.disableIndexing) return; + function ensureIndex(index, name, unique, sparse) { Meteor.startup(() => { if (collection._collection.createIndex) {