I would like to have a nested object in the detail for the activiy log. See the example. How do I define the schema in mongoose?
activity: {
date: '1/1/2012' ,
user: 'benbittly',
action: 'newIdea',
detail: {
'title': 'how to nest'
, 'url': '/path/to/idea'
}
activity: {
date: '1/2/2012' ,
user: 'susyq',
action: 'editProfile',
detail: {
'displayName': 'Susan Q'
, 'profileImageSize': '32'
, 'profileImage': '/path/to/image'
}
Use the Mixed type, which allows you to store the arbitrary sub-objects in your example.
var Activity = new Schema({
date : Date
, user : String
, action : String
, detail : Mixed
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With