Mongo db returning empty results
My code:
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'123454'};
db.collection('userinfo').find(mquery,{'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
am able to get the result from Robo3T mongo client
but same is returning null through nodejs
.
Robo3T:
db.getCollection('userinfo').find({_id:'66613'},{'_id':0,'subscriptions':1});
node.js mongodb
add a comment |
My code:
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'123454'};
db.collection('userinfo').find(mquery,{'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
am able to get the result from Robo3T mongo client
but same is returning null through nodejs
.
Robo3T:
db.getCollection('userinfo').find({_id:'66613'},{'_id':0,'subscriptions':1});
node.js mongodb
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44
add a comment |
My code:
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'123454'};
db.collection('userinfo').find(mquery,{'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
am able to get the result from Robo3T mongo client
but same is returning null through nodejs
.
Robo3T:
db.getCollection('userinfo').find({_id:'66613'},{'_id':0,'subscriptions':1});
node.js mongodb
My code:
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'123454'};
db.collection('userinfo').find(mquery,{'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
am able to get the result from Robo3T mongo client
but same is returning null through nodejs
.
Robo3T:
db.getCollection('userinfo').find({_id:'66613'},{'_id':0,'subscriptions':1});
node.js mongodb
node.js mongodb
edited Nov 20 '18 at 6:58


Sangam Belose
1,85541724
1,85541724
asked Nov 20 '18 at 4:39
Cherry gCherry g
369
369
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44
add a comment |
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44
add a comment |
1 Answer
1
active
oldest
votes
You are searching a record by {_id:'66613'}
in Robo3T
but your sample is {_id:'123454'}
in node.js. Also projection
in node.js find
is not in this way. Try below Snippet
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'66613'};
db.collection('userinfo').find(mquery).project({'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386345%2fmongo-db-returning-empty-results%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are searching a record by {_id:'66613'}
in Robo3T
but your sample is {_id:'123454'}
in node.js. Also projection
in node.js find
is not in this way. Try below Snippet
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'66613'};
db.collection('userinfo').find(mquery).project({'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
add a comment |
You are searching a record by {_id:'66613'}
in Robo3T
but your sample is {_id:'123454'}
in node.js. Also projection
in node.js find
is not in this way. Try below Snippet
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'66613'};
db.collection('userinfo').find(mquery).project({'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
add a comment |
You are searching a record by {_id:'66613'}
in Robo3T
but your sample is {_id:'123454'}
in node.js. Also projection
in node.js find
is not in this way. Try below Snippet
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'66613'};
db.collection('userinfo').find(mquery).project({'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
You are searching a record by {_id:'66613'}
in Robo3T
but your sample is {_id:'123454'}
in node.js. Also projection
in node.js find
is not in this way. Try below Snippet
MongoClient.connect(gloabl_vars.db.mongo.url,function(err, db) {
if(err) { throw err; }
var dbo=db.db("profilemanager");
var mquery={_id:'66613'};
db.collection('userinfo').find(mquery).project({'_id':0,'subscriptions':1}).toArray(function(err,result){
if(err) throw err;
console.log(result);
});
});
}
answered Nov 20 '18 at 6:09
Milad AghamohammadiMilad Aghamohammadi
841515
841515
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
add a comment |
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
Yes projection is wrong in my code. thanks for helping me in this.
– Cherry g
Nov 20 '18 at 6:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386345%2fmongo-db-returning-empty-results%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure you are searching on the correct database and/or server? That's the only possible variance you are not showing here. The drivers work fine for the other couple of million people out there using it without problem, so the only cause here is you are actually pointing at different places. Or "wrong values" since you are in fact issuing a different query to what you are dating workds
– Neil Lunn
Nov 20 '18 at 4:44