MeteorJS/MongoDB Data Structures - Which option is best for the long-term?

My team and I have run into a dilemma and wanted to get a consensus on the community here as to what would be the better option to go with.

We are trying to build a Meteor JS route like:

domain.com/main-slug/all/child-slug

The options are we either:

  1. publish the main-slug with every child-slug record or
  1. we attach the a new field to every record corresponding to that child-slug as a foreign key.

The con with publishing the main-slug with every child-slug record (option 1) would mean we would have to sub to more data and the child-slug records on this publish are already extensive (1+ million records).

The con with attaching a new field to every record corresponding to that child-slug as a foreign key (option 2) would mean we would have to rework the data and have a tougher DB migration.

In terms of optimal performance, which option would have the most pros rather than cons?

Unfortunately these kind of tasks are really only achievable in any tenable way using MongoDB’s aggregation framework

1 Like