I'm using the MEAN stack to write a web app for an existing project. The project has several MongoDB collections including one that looks like this:
{ "_id" : ObjectId("553a75a7e4b092e5edad4bce"),
"currentMessage" : "Processed.Metadata.To.MetadataDB",
"nameSpace" : "test_bulk",
"headers" : [
{ "outputFile" : "/projects/databridge/databridge-test/DataBridge/netFiles/" },
{ "className" : "org.renci.databridge.contrib.similarity.ncat.Overlap" }
]
}
I'm not having any trouble in mongoose retrieving the top level fields such as currentMessage and nameSpace, but I don't seem to be able to retrieve the headers properly. The headers are essentially a set of name value pairs. Here's my schema def (and I've tried a fair number of others):
var headerSchema = new Schema({
key:{
type: String,
default: '',
trim: true,
unique : false,
// make this a required field
required: 'key cannot be blank',
},
value:{
type: String,
default: '',
trim: true,
unique : false,
// make this a required field
required: 'value cannot be blank',
}
});
/**
* DbAction Schema
*/
var DbActionSchema = new Schema({
// Agent model fields
currentMessage: {
type: String,
default: '',
trim: true,
unique : false,
// make this a required field
required: 'currentMessage cannot be blank',
},
nameSpace: {
type: String,
default: '',
trim: true,
unique : false,
// make this a required field
required: 'nameSpace cannot be blank',
},
headers: {
type: [headerSchema],
}
});
but I can't get what I want, which is the individual fields of each header as name, value pairs. Any ideas?