Mongo, query a collection with a array

前端 未结 1 521
攒了一身酷
攒了一身酷 2021-01-24 18:48

I have this colleciton called organization:

[
  {
    \"_id\": \"53a58a02f1001e7fd28f5aec\",
    \"orgId\": 5,
          


        
相关标签:
1条回答
  • 2021-01-24 19:47

    You can match against fields within an array using dot-notation, so you can simplify your query to:

    mongoose.model('organization')
        .find({'members.user': user}, function(err, usersOrganizations){
            callback.send(200, usersOrganization);
        }
    );
    
    0 讨论(0)
提交回复
热议问题