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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현