mongoose - $all type of operator for subdocuments in mongodb -


mongo document {"objects":       { 1 : { type: "a"},       { 2 : { type: "b"},       { 3 : { type: "c"},       { 4 : { type: "a"} } desired result: {    1 : { type : "a"},   4 : { type : "a"} } 

how query above mongo document above desired result ?

looks went standard mongodb newbie trap assuming have json structure fundamental definition of mongodb used for.. looks can't query follow document structure in mongodb

elements:{   1 : { type : "a"},  4 : { type : "b"} } 

this how final document looked like:

elements: [  {id: 1, type: "a"},  {id: 4, type: "b"} ] 

the above document can queried in mongodb way: {"elements.id":1}


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -