Find document but not by _id field [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • How to query nested objects?

    2 answers



  • MongoDB wildcard in the key of a query

    1 answer



  • How to find MongoDB field name at arbitrary depth

    2 answers




I have a small issue to find/select the document by field name but i don't need to find it by id, for example:



    {
_id:ObjectId('1234567890'),
type:{
cars:{
models:
}},
_id:ObjectId('12345678901'),
type:{
boats:{
models:
}}
}


I need to select the document by "type.cars" and push into the "models" some data. The problem is that the id is not static and my be change in future, but the document structure will stay as it is "type.models". I tried to google for the solution but couldn't find anything, if you can give me an idea or a link where i can do my homework?



here is what i tried and it doesn't work for me:



findOneAndUpdate({type:'cars'},{$push: {models:{'volvo':true}}});


Thanks :)










share|improve this question













marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 1:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
    – Vadim Korolov
    Nov 12 at 1:10












  • db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
    – Vadim Korolov
    Nov 12 at 3:55

















up vote
0
down vote

favorite













This question already has an answer here:




  • How to query nested objects?

    2 answers



  • MongoDB wildcard in the key of a query

    1 answer



  • How to find MongoDB field name at arbitrary depth

    2 answers




I have a small issue to find/select the document by field name but i don't need to find it by id, for example:



    {
_id:ObjectId('1234567890'),
type:{
cars:{
models:
}},
_id:ObjectId('12345678901'),
type:{
boats:{
models:
}}
}


I need to select the document by "type.cars" and push into the "models" some data. The problem is that the id is not static and my be change in future, but the document structure will stay as it is "type.models". I tried to google for the solution but couldn't find anything, if you can give me an idea or a link where i can do my homework?



here is what i tried and it doesn't work for me:



findOneAndUpdate({type:'cars'},{$push: {models:{'volvo':true}}});


Thanks :)










share|improve this question













marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 1:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
    – Vadim Korolov
    Nov 12 at 1:10












  • db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
    – Vadim Korolov
    Nov 12 at 3:55















up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • How to query nested objects?

    2 answers



  • MongoDB wildcard in the key of a query

    1 answer



  • How to find MongoDB field name at arbitrary depth

    2 answers




I have a small issue to find/select the document by field name but i don't need to find it by id, for example:



    {
_id:ObjectId('1234567890'),
type:{
cars:{
models:
}},
_id:ObjectId('12345678901'),
type:{
boats:{
models:
}}
}


I need to select the document by "type.cars" and push into the "models" some data. The problem is that the id is not static and my be change in future, but the document structure will stay as it is "type.models". I tried to google for the solution but couldn't find anything, if you can give me an idea or a link where i can do my homework?



here is what i tried and it doesn't work for me:



findOneAndUpdate({type:'cars'},{$push: {models:{'volvo':true}}});


Thanks :)










share|improve this question














This question already has an answer here:




  • How to query nested objects?

    2 answers



  • MongoDB wildcard in the key of a query

    1 answer



  • How to find MongoDB field name at arbitrary depth

    2 answers




I have a small issue to find/select the document by field name but i don't need to find it by id, for example:



    {
_id:ObjectId('1234567890'),
type:{
cars:{
models:
}},
_id:ObjectId('12345678901'),
type:{
boats:{
models:
}}
}


I need to select the document by "type.cars" and push into the "models" some data. The problem is that the id is not static and my be change in future, but the document structure will stay as it is "type.models". I tried to google for the solution but couldn't find anything, if you can give me an idea or a link where i can do my homework?



here is what i tried and it doesn't work for me:



findOneAndUpdate({type:'cars'},{$push: {models:{'volvo':true}}});


Thanks :)





This question already has an answer here:




  • How to query nested objects?

    2 answers



  • MongoDB wildcard in the key of a query

    1 answer



  • How to find MongoDB field name at arbitrary depth

    2 answers








mongodb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 0:58









Vadim Korolov

10211




10211




marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 1:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 1:00


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
    – Vadim Korolov
    Nov 12 at 1:10












  • db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
    – Vadim Korolov
    Nov 12 at 3:55




















  • I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
    – Vadim Korolov
    Nov 12 at 1:10












  • db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
    – Vadim Korolov
    Nov 12 at 3:55


















I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
– Vadim Korolov
Nov 12 at 1:10






I dont have the value to search by as shown in that answer. I need to select the 'type.cars' and push in to models the data. The answer is different the one i am looking for.
– Vadim Korolov
Nov 12 at 1:10














db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
– Vadim Korolov
Nov 12 at 3:55






db.find().forEach(function (doc) { if(doc.cars){ db.updateOne({_id:doc._id},{$push:{'cars.models':{volvo:'xc90'}}}) } })
– Vadim Korolov
Nov 12 at 3:55



















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?