@@ -9,10 +9,6 @@ import createDebug from 'debug';
9
9
const debug = createDebug ( 'mongodb-compass:crud:crud-store' ) ;
10
10
11
11
import configureGridStore from './grid-store' ;
12
- import {
13
- buildUpdateUnlessChangedInBackgroundQuery ,
14
- getOriginalKeysAndValuesForSpecifiedKeys
15
- } from '../utils/document' ;
16
12
17
13
/**
18
14
* Number of docs per page.
@@ -378,7 +374,7 @@ const configureStore = (options = {}) => {
378
374
const {
379
375
query,
380
376
updateDoc
381
- } = buildUpdateUnlessChangedInBackgroundQuery ( doc , this . state . shardKeys ) ;
377
+ } = doc . generateUpdateUnlessChangedInBackgroundQuery ( this . state . shardKeys ) ;
382
378
383
379
if ( Object . keys ( updateDoc ) . length === 0 ) {
384
380
doc . emit ( 'update-error' , EMPTY_UPDATE_ERROR . message ) ;
@@ -420,8 +416,10 @@ const configureStore = (options = {}) => {
420
416
replaceDocument ( doc ) {
421
417
const object = doc . generateObject ( ) ;
422
418
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
+ } ) ;
425
423
this . dataService . findOneAndReplace ( this . state . ns , query , object , opts , ( error , d ) => {
426
424
if ( error ) {
427
425
doc . emit ( 'update-error' , error . message ) ;
@@ -454,8 +452,10 @@ const configureStore = (options = {}) => {
454
452
*/
455
453
replaceExtJsonDocument ( doc , originalDoc ) {
456
454
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
+ } ) ;
459
459
this . dataService . findOneAndReplace ( this . state . ns , query , doc , opts , ( error , d ) => {
460
460
if ( error ) {
461
461
this . state . updateError = error . message ;
0 commit comments