This is the code to save userDefinedSchema in the database, idea is that later i can read it back from tableSetup collection and use it to save new data for the user defined collection.
var userDefinedSchema = {
title: String,
body: String,
date:
{
type: String,
default: Date.now()
}
};
var tableUploadSetup = {
setupId:String,
userDefinedSchemaDetails:Object
};
const tableSetupSchema = new Schema(tableUploadSetup);
const newTableSetupModel = moogoose.model('TableSetup',tableSetupSchema);
const newTableSetupData = {
setupId: 'SETUP001',
userDefinedSchemaDetails:userDefinedSchema
};
const newTableSetup = new newTableSetupModel(newTableSetupData);
newTableSetupModel.save((error) =>{
if(error){
console.log('error: '+error)
} else{
console.log('data is saved !!!')
}
})
still new to mongodb, not sure whether this is the right approach. thanks for your reply.