Meteor-Community-Packages / Meteor-Community-Packages/meteor-tabular

Remove autopublish for sub-documents

Open
#453 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #454 by @ricaragao — closed without merging
Dominant language
JavaScript
Stars
360
Forks
132
PR merge metrics
No merged PRs in 30d

Description

**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:

```js
{
_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:

```js
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:

```js
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tableInit.js at line 36 and inspect how cleanFieldName transforms nested field definitions during publication. Compare the current behavior with using the original field path, then verify that selecting subDoc1.field1 and subDoc2.field3 publishes only those nested fields without breaking existing field selection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.