How can I search on a field and return the objectNoSQL (MongoDB) vs Lucene (or Solr) as your databaseHow to query MongoDB with “like”?How do I drop a MongoDB database from the command line?Search on multiple collections in MongoDBSearch backward on MongoDbHow to search for a specific pattern in MongoDB?Returning results from a date range search in MeteorObject within an Object within an Object GolangQuery an array of Objects matching word in a string fieldHow to filter in mongoDB in node to get entire object when you search for a title in the object

A conjectural trigonometric identity

Transistor design with beta variation

How were x-ray diffraction patterns deciphered before computers?

Does the problem of P vs NP come under the category of Operational Research?

Skipping same old introductions

How to structure presentation to avoid getting questions that will be answered later in the presentation?

How to set Adobe DC PDF reader as default for ALL pdfs without having to open security preferences every time

What does a number above the 'staff' mean in tablature?

What is the reason behind water not falling from a bucket at the top of loop?

Map vs. Table for index-specific operations on 2D arrays

Pre-Greek θάλασσα "thalassa" and Turkish talaz

Return last number in sub-sequences in a list of integers

speaker impedence

Can an alphabet for a Turing machine contain subsets of other alphabets?

How do I safety check that there is no light in Darkroom / Darkbag?

Why are Star Wars Rebel Alliance ships named after letters from the Latin alphabet?

What sort of solar system / atmospheric conditions, if any, would allow for a very cold planet that still receives plenty of light from its sun?

"Will flex for food". What does this phrase mean?

Backpacking with incontinence

What's the term for a group of people who enjoy literary works?

Why are sugars in whole fruits not digested the same way sugars in juice are?

Define tcolorbox in math mode

Is there a general term for the items in a directory?

Adding a (stair/baby) gate without facing walls



How can I search on a field and return the object


NoSQL (MongoDB) vs Lucene (or Solr) as your databaseHow to query MongoDB with “like”?How do I drop a MongoDB database from the command line?Search on multiple collections in MongoDBSearch backward on MongoDbHow to search for a specific pattern in MongoDB?Returning results from a date range search in MeteorObject within an Object within an Object GolangQuery an array of Objects matching word in a string fieldHow to filter in mongoDB in node to get entire object when you search for a title in the object






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I made a beer matching dating app for a school assignment. Unfortunately am I having a bit of trouble finding out how to search in my database on a template injected number as object.



I've tried this I read on MongoDB docs



The database looks like this :



beerProfile: Object
↳24589: Object
↳name: "Heineken"
img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
description: "Heinken is a beer"
bid:"24589"



So beerProfile is an object and has the object 24589 inside it. Inside the 24589 object are name, imd, description and bid.



I tried to use the find() function. ( the collection is called users )



db.collection('users').find( [24589]: [name: [Heineken]] , name: 1, bid: 1 , done);


And I also tried :



db.collection('users').find( $text: $search: 24589 , done);


I would like to make it return the object values of the 24589 object. Does anyone how I can achieve this ?










share|improve this question






























    0















    I made a beer matching dating app for a school assignment. Unfortunately am I having a bit of trouble finding out how to search in my database on a template injected number as object.



    I've tried this I read on MongoDB docs



    The database looks like this :



    beerProfile: Object
    ↳24589: Object
    ↳name: "Heineken"
    img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
    description: "Heinken is a beer"
    bid:"24589"



    So beerProfile is an object and has the object 24589 inside it. Inside the 24589 object are name, imd, description and bid.



    I tried to use the find() function. ( the collection is called users )



    db.collection('users').find( [24589]: [name: [Heineken]] , name: 1, bid: 1 , done);


    And I also tried :



    db.collection('users').find( $text: $search: 24589 , done);


    I would like to make it return the object values of the 24589 object. Does anyone how I can achieve this ?










    share|improve this question


























      0












      0








      0








      I made a beer matching dating app for a school assignment. Unfortunately am I having a bit of trouble finding out how to search in my database on a template injected number as object.



      I've tried this I read on MongoDB docs



      The database looks like this :



      beerProfile: Object
      ↳24589: Object
      ↳name: "Heineken"
      img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
      description: "Heinken is a beer"
      bid:"24589"



      So beerProfile is an object and has the object 24589 inside it. Inside the 24589 object are name, imd, description and bid.



      I tried to use the find() function. ( the collection is called users )



      db.collection('users').find( [24589]: [name: [Heineken]] , name: 1, bid: 1 , done);


      And I also tried :



      db.collection('users').find( $text: $search: 24589 , done);


      I would like to make it return the object values of the 24589 object. Does anyone how I can achieve this ?










      share|improve this question














      I made a beer matching dating app for a school assignment. Unfortunately am I having a bit of trouble finding out how to search in my database on a template injected number as object.



      I've tried this I read on MongoDB docs



      The database looks like this :



      beerProfile: Object
      ↳24589: Object
      ↳name: "Heineken"
      img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
      description: "Heinken is a beer"
      bid:"24589"



      So beerProfile is an object and has the object 24589 inside it. Inside the 24589 object are name, imd, description and bid.



      I tried to use the find() function. ( the collection is called users )



      db.collection('users').find( [24589]: [name: [Heineken]] , name: 1, bid: 1 , done);


      And I also tried :



      db.collection('users').find( $text: $search: 24589 , done);


      I would like to make it return the object values of the 24589 object. Does anyone how I can achieve this ?







      mongodb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 0:36









      Root_ishRoot_ish

      44 bronze badges




      44 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          I think your "schema" became unnecessarily complex by using a variable (24589) as a key. You should change it to something like this:



          beerProfile: Object
          ↳beer: Object
          ↳name: "Heineken"
          img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
          description: "Heinken is a beer"
          bid:"24589"


          Then you can use a simple find():



          db.collection('users').find( "beer.bid": "24589")





          share|improve this answer

























          • Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

            – Root_ish
            Mar 27 at 18:29











          • @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

            – Zolbayar
            Mar 27 at 22:59










          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368138%2fhow-can-i-search-on-a-field-and-return-the-object%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









          0














          I think your "schema" became unnecessarily complex by using a variable (24589) as a key. You should change it to something like this:



          beerProfile: Object
          ↳beer: Object
          ↳name: "Heineken"
          img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
          description: "Heinken is a beer"
          bid:"24589"


          Then you can use a simple find():



          db.collection('users').find( "beer.bid": "24589")





          share|improve this answer

























          • Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

            – Root_ish
            Mar 27 at 18:29











          • @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

            – Zolbayar
            Mar 27 at 22:59















          0














          I think your "schema" became unnecessarily complex by using a variable (24589) as a key. You should change it to something like this:



          beerProfile: Object
          ↳beer: Object
          ↳name: "Heineken"
          img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
          description: "Heinken is a beer"
          bid:"24589"


          Then you can use a simple find():



          db.collection('users').find( "beer.bid": "24589")





          share|improve this answer

























          • Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

            – Root_ish
            Mar 27 at 18:29











          • @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

            – Zolbayar
            Mar 27 at 22:59













          0












          0








          0







          I think your "schema" became unnecessarily complex by using a variable (24589) as a key. You should change it to something like this:



          beerProfile: Object
          ↳beer: Object
          ↳name: "Heineken"
          img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
          description: "Heinken is a beer"
          bid:"24589"


          Then you can use a simple find():



          db.collection('users').find( "beer.bid": "24589")





          share|improve this answer













          I think your "schema" became unnecessarily complex by using a variable (24589) as a key. You should change it to something like this:



          beerProfile: Object
          ↳beer: Object
          ↳name: "Heineken"
          img: "https://untappd.akamaized.net/site/beer_logos/beer94130_52756_sm.jpeg"
          description: "Heinken is a beer"
          bid:"24589"


          Then you can use a simple find():



          db.collection('users').find( "beer.bid": "24589")






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 3:27









          ZolbayarZolbayar

          4665 silver badges15 bronze badges




          4665 silver badges15 bronze badges















          • Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

            – Root_ish
            Mar 27 at 18:29











          • @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

            – Zolbayar
            Mar 27 at 22:59

















          • Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

            – Root_ish
            Mar 27 at 18:29











          • @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

            – Zolbayar
            Mar 27 at 22:59
















          Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

          – Root_ish
          Mar 27 at 18:29





          Thank you for your response. This is a really good solution thank you! How would you add a second beer to the beer profile ? As duplicates aren't allowed. Or is there a workaround ?

          – Root_ish
          Mar 27 at 18:29













          @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

          – Zolbayar
          Mar 27 at 22:59





          @Root_ish, then you have to make it an array which can hold multiple beer objects. beer: [ name: "Heineken" bid: 24589 , name: "Bud" bid: 24590 ], etc.

          – Zolbayar
          Mar 27 at 22:59








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368138%2fhow-can-i-search-on-a-field-and-return-the-object%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript