node.js - nodejs, mongodb get array of only specified fields value -


is possible array of specified fields value in mongodb?

like instead of getting:

[{"color":"blue"},{"color":"red"}] 

i get:

["blue","red"] 

is question clear enough?

you can run array.map on results array achieve desired result:

var colors = [{"color":"blue"},{"color":"red"}].map(function(obj){     return obj.color; }); 

Comments

Popular posts from this blog

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -