How to add data to mongodb?

  mongodb, question

There is an array cateogoryList in the defined Schema:

const mongoose = require('mongoose');
 const Schema = mongoose.Schema;
 
 const ProductCateogorySchema = new Schema({
 user:{
 type:Schema.Types.ObjectId,
 ref:"users"
 },
 cateogoryList:[
 {
 cateogoryName:{
 type:String,
 required:true
 },
 cateogoryDes:{
 type:String
 }
 },
 {
 cateogorySubList:[
 
 ]
 }
 ],
 date:{
 type:Date,
 default:Date.now
 }
 });
 
 module.exports = mongoose.model('cateogories',ProductCateogorySchema);

Now it is through the form to add data to this array. Under normal circumstances, it is necessary to query from this Schema, find this cateogoryList, then add data, and finally save it. However, I encounter such a problem here:
I cannot operate this cateogoryList array in the Schema, or I don’t know how to operate it, and then I can’t write data.
The front is the POST method:

router.post('/cateogory/add',urlencodedParser,(req,res) => {
 CateogoryOneSchema.find().then(cateogory => {
 if(!  cateogory){
 console.log('cateogory    :'  + cateogory)
 const newFields = {
 cateogoryName: req.body.cateogoryOneName,
 cateogoryDes:req.body.cateogoryOneDes
 }
 
 const category = {};
 category.categoryList = [];
 category.categoryList.push(newFields);
 cateogory.save();
 }
 })
 })

Cateogory printed is empty data that was just inserted unsuccessfully:
图片描述

However, when using category.categoryList, an error will be reported that push cannot be used. How should I operate?
Thank you very much

The feeling is that there is something wrong with Schema design, if the array is removed, the addition can be successful, like this:

const ProductCateogorySchema = new Schema({
 user:{
 type:Schema.Types.ObjectId,
 ref:"users"
 },
 product:[],
 cateogoryName:{
 type:String,
 required:true
 },
 cateogoryDes:{
 type:String
 },
 subTwoCateogory:[],
 subThreeCateogory:[],
 date:{
 type:Date,
 default:Date.now
 }
 });
router.post('/cateogory/add',urlencodedParser,(req,res) => {
 const newFields = {
 cateogoryName: req.body.cateogoryOneName,
 cateogoryDes:req.body.cateogoryOneDes
 }
 
 new CateogoryOneSchema(newFields).save().then(cateogories => {
 res.redirect('/product/cateogory');
 res.send(cateogories);
 }).catch(err => {
 console.log(err)
 });
 })
 In this way, the addition can be successful, but if there is an array, the array cannot be read from the database, and then the addition fails all the time.