3

I have a CRUD-entity with a strong relationship to another entity, like comments only be posted and viewed above an article.

I want to use document db structure. Every comment should be saved in its article. I dont want to have a comments collection in which every comment is saved and referenced from the articles collection, like a relational db structure would suggest.

My question now is: What is the best practice to create a document style sub crud module in MEAN.JS?

Should I...

  • generate it, disable the creation in the collection and link the angular-controllers/views across the modules?
  • generate it, disable the creation in the collection and move the files to the father crud module?
  • refrain from generating it, create all needed files direct in the father module?
JoeFahrrad
  • 63
  • 4

2 Answers2

1

Create all needed files direct in the father module.

I did something similar to avoid referencing to other documents, you can edit the module schema to embed a schema into a schema, check this link:

http://www.jonahnisenson.com/schema-within-a-schema-use-embedded-documents-in-mongoosemongo/

Luke Kroon
  • 1,016
  • 12
  • 19
0

You don't have to generate a separate CRUD Module for it. Generate a normal CRUD Module for the Articles and in the server sub-folder, you can create the model of the comments. After creating the Comments Model, You can then create another Model for Articles and then you refer to the Comments Model as part of the Article Model.

Joseph Joestar
  • 468
  • 1
  • 6
  • 11