MeanJS: Generate Sub-CRUD module with generator?

I have a CRUD object with a strong relationship to another object, for example, comments are posted and viewed above the article.

I want to use the db document structure. Each comment should be saved in his article. I don't want to have a collection of comments where each comment is saved and referenced to a collection of articles, like a db relational structure.

Now my question is: What is the best practice for creating a document style sub crud module in MEAN.JS?

Should I...

  • generate it, disable creation in the collection and link angular-controllers / views modulo?
  • generate it, disable creation in collection and move the files to the crud module of the father.
  • refrain from creating it, create all the necessary files directly in the father module?
+3


source to share


2 answers


Create all the necessary files directly in the fathers module.

I did something like this so as not to link to other docs, you can edit the module schema to embed the schema in the schema, check this link:



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

+1


source


You don't need to create a separate CRUD module for it. Create a normal CRUD module for articles and in the server subfolder you can create a comment model. After creating the comment model, you can create another model for articles, and then reference the comment model as part of the article model.



0


source







All Articles