Is it very bad for Node to use mongoose of mongodb?

  node.js, question

Is it very bad for Node to use mongoose of mongodb?

var CategorySchema = new Schema({
 _id: {
 type: String,
 unique: true,
 'default': shortid.generate
 },
 Name: String, // name
 Remark: String, // introduction
 Sort: number//sort
 Type:Number, // Category (1: Technology, 2: Reading, 3: Life)
 Level:Number, // directory level (1: primary directory, 2: secondary directory)
 Parentid: {type: string, ref:' category'},//parent directory
 Userid: {type: string, ref:' user'}//user name
 });

There is a directory model like the one above, how can I query the primary directory and the secondary directories it contains?

The question you raised is notmongooseIt’s a problem with the storage model you designed.

One of mongodb’s documentsChapterIt specifically introduces how to store data with tree structure. It introduces five situations, each of which has its advantages and disadvantages. among themThe second caseIt is close to your needs, and the idea is to add one to the schema.childrenProperty, used to save the next level of references, you can refer to.

The model you are designing now belongs to these five situations.First caseIt is convenient for children to check their parents.