electrodb icon indicating copy to clipboard operation
electrodb copied to clipboard

Setter not triggered on removing a watching attribute

Open jw-meta opened this issue 1 year ago • 1 comments

Describe the bug with attribute updatedAt having property watch: ['status'] the attribute updatedAt setter is not triggered when patch.remove() is called to remove the attribute status

it works as expected when watch: '*' is set

ElectroDB Version 2.13.1

ElectroDB Playground Link config with watch as array of attribute names config with watch as wildcard

Entity/Service Definitions

{
  model: {
    entity: "tasks",
      version: "1",
        service: "taskapp"
  },
  attributes: {
    id: {
      type: "string",
        required: true
    },
    status: {
      type: 'string'
    },
    createdAt: {
      type: "number",
        default: () => Date.now(),
        readOnly: true
    },
    updatedAt: {
      type: "number",
        watch: ['status'],
          set: () => Date.now(),
            readOnly: true
    }
  },
  indexes: {
    projects: {
      pk: {
        field: "pk",
          composite: ["id"]
      },
    },
  }
}

Expected behavior The setter of updated_at should be triggered on removing status attribute with patch.remove()

jw-meta avatar Jun 18 '24 16:06 jw-meta

Thank you, I will look into this!

tywalch avatar Jul 04 '24 13:07 tywalch