user2925894
user2925894

Reputation: 259

Mongodb, find just one of the names in database when multiple stored

I've got a problem when finding from our mongoDB.

Imagine having a mongodb like this: {name: John}, {name: John}, {name: Otto} {name: Louise}, {name: Sarah}, {name: Louise}

our web-server.js is like:

app.get('/names/*', function(req, res){
 names.find({}, function(err, names){
res.json(names);
}); });

i get John, John, Otto, Louise, Sarah, Louise in result. Is there a way i can get only John, Otto, Louise and Sarah?

Upvotes: 1

Views: 66

Answers (1)

Torby
Torby

Reputation: 144

You should look at using a filter in the HTML-page. Like this:

{Names | unique}

The documents can be viewed here:

http://docs.angularjs.org/api/ng/filter/filter

Upvotes: 1

Related Questions