2016-03-24 105 views
-1
{ artists: 
    { id: '324435', 
    name: 'Gleen' 
}, 
    albums: 
    [ { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] }, 
    { album: [Object], tracks: [Object] } ] } 

如何在mongoose中聲明模式以便我可以保存爲mongodb?類型:正常對象值的字符串,但它是一個對象數組呢?Moongse schema with array

回答

1

Schema @zangw回答也可以,但這是另一種方法。

var scheme = new mongoose.Scheme({ 
    artists : { 
     id : String, 
     name : String 
    }, 
    albums : [{ 
     album : {/*object details*/}, 
     tracks : {/*object details*/} 
    }] 
}); 
+0

不起作用... –