Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling indexing #31

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:[email protected]`, `ecmascript` according to Meteor version)
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package/indexing/package.js
Original file line number Diff line number Diff line change
@@ -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",
});
Expand Down
2 changes: 2 additions & 0 deletions package/indexing/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down