Nodejs mongoose sub sub document searchHow can I update NodeJS and NPM to the next versions?How do I update/upsert a document in Mongoose?NodeJs, Mocha and MongooseBest way to perform a full text search in MongoDB and MongooseHow to create Schema using mongodb(mongoose schema)?How to popoulate recursive schema references Mongodb, Mongoose, Express?Mongoose populate with match condition for nested documentMongoDB/ Mongoose many to many relationship - user, project and roleHow to make mongoose schema property of type (another) schema requiredMongoose: Add validators on the fly on some parameters depending on queries

mini sub panel?

Whose birthyears are canonically established in the MCU?

Opposite party turned away from voting when ballot is all opposing party

Crime rates in a post-scarcity economy

Light Switch Neutrals: Bundle all together?

Wiper fluid only squirts out for a second - Hyundai Accent 2006

Expl3 and recent xparse on overleaf: No expl3 loader detected

What are my options legally if NYC company is not paying salary?

Why are thrust reversers not used down to taxi speeds?

Does this website provide consistent translation into Wookiee?

Why does this pattern in powers happen?

Why doesn't increasing the temperature of something like wood or paper set them on fire?

How to explain intravenous drug abuse to a 6-year-old?

I'm attempting to understand my 401k match and how much I need to contribute to maximize the match

What happens when the drag force exceeds the weight of an object falling into earth?

How would an instant or sorcery with an effect that targets work with Feather?

Is it safe to keep the GPU on 100% utilization for a very long time?

Is your maximum jump distance halved by grappling?

How is it believable that Euron could so easily pull off this ambush?

Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1

How to avoid making self and former employee look bad when reporting on fixing former employee's work?

What is the oldest instrument ever?

How to append code verbatim to .bashrc?

Can a character shove an enemy who is already prone?



Nodejs mongoose sub sub document search


How can I update NodeJS and NPM to the next versions?How do I update/upsert a document in Mongoose?NodeJs, Mocha and MongooseBest way to perform a full text search in MongoDB and MongooseHow to create Schema using mongodb(mongoose schema)?How to popoulate recursive schema references Mongodb, Mongoose, Express?Mongoose populate with match condition for nested documentMongoDB/ Mongoose many to many relationship - user, project and roleHow to make mongoose schema property of type (another) schema requiredMongoose: Add validators on the fly on some parameters depending on queries






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have schema like



const propertiesSchema = new Schema(
name:
type: String,
required: true
,
shortDescription: String,
totalArea: String,
address:
type: mongoose.Schema.Types.ObjectId,
ref: "Address",
required: true

)


and the address schema like this



const addressSchema = new Schema(
addressLine1:
type:String,
required:false
,
addressLine2:
type:String,
required:false
,
city:
type:mongoose.Schema.Types.ObjectId,
required:true,
ref:"City"

)


and i want to search city from propertiesSchema am using mongoose for the mongodb. and also i have optional searchData object like



searchData = 
"name":"test"
"city":"5c8f7f178dec7c20f4783c0d"



here the city id may be null and i need if the city id not null then only need to search city on propertiesSchema . please help to solve this problem. thank you..










share|improve this question




























    0















    I have schema like



    const propertiesSchema = new Schema(
    name:
    type: String,
    required: true
    ,
    shortDescription: String,
    totalArea: String,
    address:
    type: mongoose.Schema.Types.ObjectId,
    ref: "Address",
    required: true

    )


    and the address schema like this



    const addressSchema = new Schema(
    addressLine1:
    type:String,
    required:false
    ,
    addressLine2:
    type:String,
    required:false
    ,
    city:
    type:mongoose.Schema.Types.ObjectId,
    required:true,
    ref:"City"

    )


    and i want to search city from propertiesSchema am using mongoose for the mongodb. and also i have optional searchData object like



    searchData = 
    "name":"test"
    "city":"5c8f7f178dec7c20f4783c0d"



    here the city id may be null and i need if the city id not null then only need to search city on propertiesSchema . please help to solve this problem. thank you..










    share|improve this question
























      0












      0








      0


      1






      I have schema like



      const propertiesSchema = new Schema(
      name:
      type: String,
      required: true
      ,
      shortDescription: String,
      totalArea: String,
      address:
      type: mongoose.Schema.Types.ObjectId,
      ref: "Address",
      required: true

      )


      and the address schema like this



      const addressSchema = new Schema(
      addressLine1:
      type:String,
      required:false
      ,
      addressLine2:
      type:String,
      required:false
      ,
      city:
      type:mongoose.Schema.Types.ObjectId,
      required:true,
      ref:"City"

      )


      and i want to search city from propertiesSchema am using mongoose for the mongodb. and also i have optional searchData object like



      searchData = 
      "name":"test"
      "city":"5c8f7f178dec7c20f4783c0d"



      here the city id may be null and i need if the city id not null then only need to search city on propertiesSchema . please help to solve this problem. thank you..










      share|improve this question














      I have schema like



      const propertiesSchema = new Schema(
      name:
      type: String,
      required: true
      ,
      shortDescription: String,
      totalArea: String,
      address:
      type: mongoose.Schema.Types.ObjectId,
      ref: "Address",
      required: true

      )


      and the address schema like this



      const addressSchema = new Schema(
      addressLine1:
      type:String,
      required:false
      ,
      addressLine2:
      type:String,
      required:false
      ,
      city:
      type:mongoose.Schema.Types.ObjectId,
      required:true,
      ref:"City"

      )


      and i want to search city from propertiesSchema am using mongoose for the mongodb. and also i have optional searchData object like



      searchData = 
      "name":"test"
      "city":"5c8f7f178dec7c20f4783c0d"



      here the city id may be null and i need if the city id not null then only need to search city on propertiesSchema . please help to solve this problem. thank you..







      node.js mongoose mongoose-schema mongoose-populate nodejs-server






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 7:19









      soorajsooraj

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          0














          As city is an nested object you can query that like



          "address.city"



          Eg: 

          searchData =
          "name":"test"
          "address.city":"5c8f7f178dec7c20f4783c0d"



          UPDATE



          '5c8f7f178dec7c20f4783c0d' is a string. You should use



          const mongoose = require('mongoose');
          mongoose.Types.ObjectId('5c8f7f178dec7c20f4783c0d');





          share|improve this answer

























          • but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

            – sooraj
            Mar 29 at 5:43












          • but even now its return the empty array not returning the filtered array

            – sooraj
            Mar 29 at 12:07











          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%2f55311540%2fnodejs-mongoose-sub-sub-document-search%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














          As city is an nested object you can query that like



          "address.city"



          Eg: 

          searchData =
          "name":"test"
          "address.city":"5c8f7f178dec7c20f4783c0d"



          UPDATE



          '5c8f7f178dec7c20f4783c0d' is a string. You should use



          const mongoose = require('mongoose');
          mongoose.Types.ObjectId('5c8f7f178dec7c20f4783c0d');





          share|improve this answer

























          • but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

            – sooraj
            Mar 29 at 5:43












          • but even now its return the empty array not returning the filtered array

            – sooraj
            Mar 29 at 12:07















          0














          As city is an nested object you can query that like



          "address.city"



          Eg: 

          searchData =
          "name":"test"
          "address.city":"5c8f7f178dec7c20f4783c0d"



          UPDATE



          '5c8f7f178dec7c20f4783c0d' is a string. You should use



          const mongoose = require('mongoose');
          mongoose.Types.ObjectId('5c8f7f178dec7c20f4783c0d');





          share|improve this answer

























          • but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

            – sooraj
            Mar 29 at 5:43












          • but even now its return the empty array not returning the filtered array

            – sooraj
            Mar 29 at 12:07













          0












          0








          0







          As city is an nested object you can query that like



          "address.city"



          Eg: 

          searchData =
          "name":"test"
          "address.city":"5c8f7f178dec7c20f4783c0d"



          UPDATE



          '5c8f7f178dec7c20f4783c0d' is a string. You should use



          const mongoose = require('mongoose');
          mongoose.Types.ObjectId('5c8f7f178dec7c20f4783c0d');





          share|improve this answer















          As city is an nested object you can query that like



          "address.city"



          Eg: 

          searchData =
          "name":"test"
          "address.city":"5c8f7f178dec7c20f4783c0d"



          UPDATE



          '5c8f7f178dec7c20f4783c0d' is a string. You should use



          const mongoose = require('mongoose');
          mongoose.Types.ObjectId('5c8f7f178dec7c20f4783c0d');






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 29 at 8:37

























          answered Mar 29 at 5:01









          Viswanath LekshmananViswanath Lekshmanan

          7,63012953




          7,63012953












          • but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

            – sooraj
            Mar 29 at 5:43












          • but even now its return the empty array not returning the filtered array

            – sooraj
            Mar 29 at 12:07

















          • but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

            – sooraj
            Mar 29 at 5:43












          • but even now its return the empty array not returning the filtered array

            – sooraj
            Mar 29 at 12:07
















          but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

          – sooraj
          Mar 29 at 5:43






          but i get the error when i trying this UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value " city: '5c8f7f178dec7c20f4783c0d' " at path "address" for model "Properties"

          – sooraj
          Mar 29 at 5:43














          but even now its return the empty array not returning the filtered array

          – sooraj
          Mar 29 at 12:07





          but even now its return the empty array not returning the filtered array

          – sooraj
          Mar 29 at 12:07



















          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%2f55311540%2fnodejs-mongoose-sub-sub-document-search%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권, 지리지 충청도 공주목 은진현