javascript - mongo database retrieval problem
巴扎黑
巴扎黑 2017-05-18 10:48:51
0
1
368

Every person in the database has the same attribute, which is the department. I want to get all the departments that appear in the database (no duplication). For example, there are 4 people in the database. No. 1 is the marketing department and No. 2 is sales. Department No. 3 is the office and No. 4 is the marketing department
Then the array I need is ['Marketing Department', 'Sales Department', 'Office']. How can I get this array? I use node.js mongose ​​mongodb in the background.

巴扎黑
巴扎黑

reply all(1)
给我你的怀抱

For reference:

db.collection.distinct()

https://docs.mongodb.com/manu...

I’m thinking that it might be more efficient if I check the official documentation myself: http://docs.mongodb.org/manual/.

Love MongoDB! Have fun!


The 2017 MongoDB Chinese Community Beijing User Group Conference is coming soon, June 3, 2017 13:00-18:00

Many wonderful sharings! Worth participating!

For details, please follow the "MongoDB Chinese Community" official account.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!