I have a file which has key as IP "10.11.190.14:cgi6web-1": . When I try to insert the file in mongoDB, I get the following error:
Error: key 10.11.190.14:cgi6-web-1 must not contain '.' at Error (unknown source).
I dont have permissions to change the file , is there any work around to write the file to mongoDB with IP as key.
My Code is as follows:
var MongoClient = require('./lib/mongodb').MongoClient;
var file = require (__dirname + '/functions.json');
MongoClient.connect('mongodb://phx8b03c-fb1d',
function (err, client) {
if (err) throw err;
client.createCollection('lbTopology' , function (err, collection) {
if (err) throw err;
collection.insert(file, 'lbTopology' , function (err) {
if (err) throw err;
client.close(function (err) {
if (err) throw err;
console.log('done');
});
});
});
})
Can someone please help me with this?
{ "10.11.190.14:cgi6web-1": ... }, maybe{ "key": "10.11.190.14:cgi6web-1", ... }? It would probably make querying simpler later:collection.find({ key: '10.11.190.14:cgi6web-1' }, ...).