Skip to content

Commit d9bc07c

Browse files
authored
chore(compass-crud, hadron-document): Move document helpers from compass-crud to hadron-document COMPASS-4882 (#2242)
1 parent 10af07b commit d9bc07c

File tree

7 files changed

+1074
-885
lines changed

7 files changed

+1074
-885
lines changed

packages/compass-crud/src/stores/crud-store.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import createDebug from 'debug';
99
const debug = createDebug('mongodb-compass:crud:crud-store');
1010

1111
import configureGridStore from './grid-store';
12-
import {
13-
buildUpdateUnlessChangedInBackgroundQuery,
14-
getOriginalKeysAndValuesForSpecifiedKeys
15-
} from '../utils/document';
1612

1713
/**
1814
* Number of docs per page.
@@ -378,7 +374,7 @@ const configureStore = (options = {}) => {
378374
const {
379375
query,
380376
updateDoc
381-
} = buildUpdateUnlessChangedInBackgroundQuery(doc, this.state.shardKeys);
377+
} = doc.generateUpdateUnlessChangedInBackgroundQuery(this.state.shardKeys);
382378

383379
if (Object.keys(updateDoc).length === 0) {
384380
doc.emit('update-error', EMPTY_UPDATE_ERROR.message);
@@ -420,8 +416,10 @@ const configureStore = (options = {}) => {
420416
replaceDocument(doc) {
421417
const object = doc.generateObject();
422418
const opts = { returnOriginal: false, promoteValues: false };
423-
const query = getOriginalKeysAndValuesForSpecifiedKeys(
424-
doc, { _id: 1, ...(this.state.shardKeys || {}) });
419+
const query = doc.getOriginalKeysAndValuesForSpecifiedKeys({
420+
_id: 1,
421+
...(this.state.shardKeys || {})
422+
});
425423
this.dataService.findOneAndReplace(this.state.ns, query, object, opts, (error, d) => {
426424
if (error) {
427425
doc.emit('update-error', error.message);
@@ -454,8 +452,10 @@ const configureStore = (options = {}) => {
454452
*/
455453
replaceExtJsonDocument(doc, originalDoc) {
456454
const opts = { returnOriginal: false, promoteValues: false };
457-
const query = getOriginalKeysAndValuesForSpecifiedKeys(
458-
originalDoc, { _id: 1, ...(this.state.shardKeys || {}) });
455+
const query = originalDoc.getOriginalKeysAndValuesForSpecifiedKeys({
456+
_id: 1,
457+
...(this.state.shardKeys || {})
458+
});
459459
this.dataService.findOneAndReplace(this.state.ns, query, doc, opts, (error, d) => {
460460
if (error) {
461461
this.state.updateError = error.message;

packages/compass-crud/src/utils/document.js

-160
This file was deleted.

0 commit comments

Comments
 (0)