2017-12-03 3 views
0

을 절약하고 난 내가 잘못하고있는 무슨 빈 배열을 가지고 몽구스와 함께하지만 수익에 삽입하려고 :몽구스,</p> <p>내 스키마를 내가 배열을 빈 배열

console.log(req.body.type); //here i have something like ["Teste1","Teste2"] 
let post = new Post({ 
         name: req.body.descricao, 
         desc: req.body.desc 
         type: req.body.type 
        }); 

post.save((err, model) => { 

    if (err) console.log(err); 

    if (model) console.log(model); //ALL INSERTED but array is just type:[] 

}) 
+1

게시물을 저장하는 동안 모델 인수가 없습니다. –

답변

0

가장 좋은 방법은 배열 요소의 유형을 지정하는 것입니다. 빈 배열 지정 예컨대 는

type: [String] 

혼합형 동일하다. 또한 req.body.type의 유형을 확인하십시오.

console.log(typeof req.body.type)