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
Post a Comment