vuex-orm / plugin-change-flags

Vuex ORM plugin for adding IsDirty / IsNew flags to model entities.
MIT License
24 stars 10 forks source link

For single instance cannot set isDirty: false using update (vuex-orm-core .36.3 and change-flags 1.2.3) #12

Closed vikaskedia closed 4 years ago

vikaskedia commented 4 years ago

The code I am running is:

  console.log("trying to set isdirty false")
  ormRem.update({
    data: { 
      uuid: item.uuid,
      '$isDirty': false, 
    },
    preventDirtyFlag: true
  }).then(result => {
    console.log('update result: ', result)
  })
})

The output I get is:

image

The definition of model is at: https://github.com/savantcare/ptfile/blob/master/ptclient/components/rem/vuex-orm/model.js

import { Model } from '@vuex-orm/core'
const { v1: uuidv1 } = require('uuid')

export default class reminders extends Model {
  // This is the name used as module name of the Vuex Store.
  static entity = 'rem'

  static primaryKey = 'uuid' // Ref: https://vuex-orm.org/guide/model/defining-models.html#primary-key

  // List of all fields (schema) of the post model. `this.attr` is used
  // for the generic field type. The argument is the default value.
  static fields() {
    return {
      uuid: this.uid(() => uuidv1()),
      uuidOfRemMadeFor: this.attr(null),
      remDescription: this.attr(null),
      notes: this.attr(null),
      priority: this.number(0),
      isAutoRem: this.number(0),
      recordChangedByUUID: this.attr(null),
      recordChangedFromIPAddress: this.attr(null),
      recordChangedFromSection: this.attr(null),
      // Why store time as a number? Since vuex-orm does not understand dates.
      // The data types that vuex-orm understands are given at: https://vuex-orm.org/guide/model/defining-models.html#generic-type
      ROW_START: this.number(0),
      ROW_END: this.number(0),
    }
  }
}

Is this a bug?

vikaskedia commented 4 years ago

Duplicate of https://github.com/vuex-orm/plugin-change-flags/issues/9#issuecomment-616506953