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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃敡 Allow disabling the src/seq/v index #157

Merged
merged 1 commit into from
May 28, 2024
Merged

Conversation

alecgibson
Copy link
Contributor

This change is to work alongside upstream work to remove ShareDB's usage of getCommittedOpVersion().

In sharedb-mongo this function requires an entire extra op index, just to handle a corner case where two create ops are submitted at the same time, which should happen relatively infrequently.

This change allows consumers to opt out of individual indexes. For example, if we're not using getCommittedOpVersion(), consumers can opt out of the automatic src/seq/v index creation with:

new ShareDbMongo(
  mongoUrl,
  {
    disableIndexCreation: {
      src_seq_v: true,
    },
  },
);

Note that if this index already exists, consumers will need to manually remove it.

Previous behaviour will still work, so setting:

new ShareDbMongo(
  mongoUrl,
  {
    disableIndexCreation: true,
  },
);

disables all index creation.

- Fixes #94
- Follows on from share/sharedb#657

This change is to work alongside upstream work to remove ShareDB's
usage of `getCommittedOpVersion()`.

In `sharedb-mongo` this function requires an entire extra op index,
just to handle a corner case where two `create` ops are submitted at the
same time, which should happen relatively infrequently.

This change allows consumers to opt out of individual indexes. For
example, if we're not using `getCommittedOpVersion()`, consumers can
opt out of the automatic `src`/`seq`/`v` index creation with:

```js
new ShareDbMongo(
  mongoUrl,
  {
    disableIndexCreation: {
      src_seq_v: true,
    },
  },
);
```

Note that if this index already exists, consumers will need to manually
remove it.

Previous behaviour will still work, so setting:

```js
new ShareDbMongo(
  mongoUrl,
  {
    disableIndexCreation: true,
  },
);
```

disables **all** index creation.
@coveralls
Copy link

Coverage Status

coverage: 92.725% (+0.1%) from 92.593%
when pulling 763baa6 on no-src-seq-index
into 7e88b0a on master.

@alecgibson alecgibson merged commit 162b81c into master May 28, 2024
26 checks passed
@alecgibson alecgibson deleted the no-src-seq-index branch May 28, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tidy up src/seq fields and use a sparse index?
3 participants