mongodb - Why is the database empty, even after a successful import? -


i attempted import json file today on macbook, got error:

davids-macbook-pro:server droberts$  node import.js /filepath/a_to_b.json   development mongodb://localhost/somefoldername { db: { safe: true } } b  /users/droberts/desktop/foldera/folderb/node_modules/mongoose/node_modules/mongodb/lib/server.js:236     process.nexttick(function() { throw err; })                                         ^ error: connect econnrefused @ exports._errnoexception (util.js:746:11) @ tcpconnectwrap.afterconnect [as oncomplete] (net.js:1010:19) 

however, after running mongod in new tab, able rerun command successfully:

davids-macbook-pro:server droberts$  node import.js  /filepath/a_to_b.json  development mongodb://localhost/somefoldername { db: { safe: true } } b adding data mongodb finished import 

however, startling thing is, database remains empty!:

davids-macbook-pro:server droberts$ mongo mongodb shell version: 3.2.1 connecting to: test server has startup warnings:  2016-01-15t17:50:09.158-0500 control  [initandlisten] ** warning:     running process root user, not recommended. 2016-01-15t17:50:09.158-0500 control  [initandlisten]  2016-01-15t17:50:09.158-0500 control  [initandlisten]  2016-01-15t17:50:09.158-0500 control  [initandlisten] ** warning: soft rlimits low. number of files 256, should @ least 1000 > show dbs somefoldername 0.000gb local          0.000gb 

what on earth going on?!!! here source node.js:

'use strict';  // set default node environment development process.env.node_env = process.env.node_env || 'development';  console.log(process.env.node_env); var mongoose = require('mongoose'); var config = require('./config/environment'); var citypair = require('./api/citypair/citypair.model');  console.log(config.mongo.uri) console.log(config.mongo.options)  // connect database mongoose.connect(config.mongo.uri, config.mongo.options);  var fs = require('fs'); var file = json.parse(fs.readfilesync(process.argv[2], 'utf8')); console.log(file.startcity.name) console.log(file.endcity.name)  //citypair.find({}).remove( citypair.find({   $or: [{startcity : file.startcity, endcity : file.endcity},         {startcity : file.endcity, endcity : file.startcity}]   }).remove(   function() {     console.log('adding data mongodb');     citypair.create(file, function(err){       console.log('finished import');       process.exit();     });   } ); 


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -