node.js - Mongoose Query Nested Data Multiple Word Key -


i cannot find example of how build query property name of nested property multiple words.

var student = {   name: 'kevin',   address: {     'street 1': '123 main',     'street 2': 'apt 2'     city: 'chicago' };  // works. var query = student.find({   'address.city': 'chicago' }); 

i cannot figure out how query street 1.

// tried this. did not work. var query = student.find({   'address["street 1"]': '123 main' }); 

use same dot notation syntax, should work:

// tried this. works. var query = student.find({   'address.street 1': '123 main' }); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -