5
Sono nuovo con nodeJS e MongoDB. Ho questo codice:come inserire un documento .json nel server mongo di mongojs nel nodo
var fs = require('fs');
var mongojs = require('mongojs');
var db = mongojs('monitor', ["configurations"]);
fs.readFile('json/object1.json', 'utf8', function (err, data) {
if (err) throw err;
console.log(data);
db.configurations.insert(data, function(err, doc) {
console.log(data);
if(err) throw err;
});
});
nessun dato insered al MongoDB, e ho alcun errore. entrambi console.log (dati) stampano anche la stringa json.
Grazie !! Sta funzionando. – Avigayil