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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

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

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -