Skip to content

Remove autopublish for sub-documents #453

@raragaodl

Description

@raragaodl

Is your feature request related to a problem? Please describe.

I'm using Tabular with a collection with many fields and a lot of them in subdocuments
Example:

{
  _id: 'aaaaa',
  subDoc1: {
    field1: 'a',
    field2: 'b',
  },
  subDoc2: {
    field3: 'c',
    field4: 'd',
  }
}

So when I want to create a tabular with the field1 and field3, I just put definition of data as 'subDoc1.field1', and 'subDoc2.field3'. This works fine, no issues
The problem is that Tabular publish just use the top level field name to publish the document. Then, all fields are being published to the client.

Describe the solution you'd like
I took a look on the code and see in the file tableInit.js a line that remove the sub-fields name, returning just the main level of the fields. The line is 36 with the code:

fields[cleanFieldName(data)] = 1;

Describe alternatives you've considered
None

Additional context

I did a test to my scenario removing the cleanFieldName call, and all the functions seems as fine.
new code:

fields[data] = 1;

Just to understanding, with this change I could reduce data size on client in 80% in my case, and I don't expose any unnecessary data to client.

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