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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -