Skip to content

Mark documents with the component that created them. #40

@SilasBerger

Description

@SilasBerger

Context: I believe there are valid reasons for letting multiple frontend components use the same document type. However, consider the following scenario:

  1. I implement a component <Foo> and use a new document typ something_generic with that component.
  2. I implement another component <Bar>, which happens to fit the exact data model of the something_generic document type – so, I reuse that type.
  3. <Foo> and <Bar> now both save documents of type something_generic.

Problem: <Foo> evolves over time and now requires a completely different data model. <Bar>, however, hasn't changed and isn't expected to. So, I now need a new document type something_else and I need to migrate all <Foo>-related documents to that new type. This is problematic: How can I select and modify all something_generic documents that were created by <Foo>, without affecting those created by <Bar>

Suggested solution: Add a new component column to the document table. When saving a document of type something_generic, the <Foo> component would set component to Foo while <Bar> would set it to Bar. That way, when the above scenario occurs, we can SELECT * FROM documents WHERE type='something_generic' AND component='Foo'; and migrate all those documents to the new something_else type.

Disadvantage: We would be saving an additional field for every document that is never read under normal circumstances.

Alternative solution: Implement the component field on the document_root. With that, we would only have to persist the field once per instance of each component in the frontend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions