My problem consists of creating a collection with dynamic fields and undefined names which should be entered by the user. So I tried doing it using variables but it's not working.
This is the code
insertData_dynamic_colone : function(collection) {
var colone1 = "prod";
var colone2 = "prod2";
dbObject.collection(collection).insertOne({
colone1 : "14",
colone2 : "15"
}, function(err, result) {
assert.equal(err, null);
});
},
So on the database I am getting
> db.colone_dynamic.find()
{ "_id" : ObjectId("579af3c4f41e03f0362a5170"), "colone1" : "14", "colone2" : "15" }
But I'm expecting to get
> db.colone_dynamic.find()
{ "_id" : ObjectId("579af3c4f41e03f0362a5170"), "prod" : "14", "prod2" : "15" }