دنبال کننده ها

۱۳۹۷ فروردین ۸, چهارشنبه

node.js - Nodejs mongodb don't woking on server

[ad_1]



On local, I installed NodeJS 9.2 and MongoDB 3.4



I using MongoDB Native Node Driver 3.0.4



My code with database



const mongo = require('mongodb').MongoClient;
const mongoose = require('mongoose');

mongo.connect('mongodb://localhost:27017/my_database', function(err, client)
console.log(err);
if (!err)
var database = client.db('my_database');
database.collection('users').find().toArray(function(err, docs)
console.log(docs);
);

);


Result null for error and array users in collection



So, on server centos 7 installed nodejs 8.2, Result null for error and empty array for docs



How does it work?




[ad_2]

لینک منبع