mongo queries the specified field, where the query condition is empty

1.Mongo query the specified field, where the query condition is empty

db.test.find({},{projectId:1, envId:1 ,subjectNo:1})

2. How to implement an inner join query between two tables ** I have
n't found a suitable method yet**
My solution: The method
in sql is similar:
select b.subject_id, b.environmentId from db.test a inner join subject_form_statistic1 b where a .projectId=b.study_id and a.envId=b.environmentId and a.subjetNo=b.subject_subject_no
1. Use db.test.find({},{projectId:1, envId:1 ,subjectNo:1})the fields of projectId, envId, and subjectNo to find out and temporarily store the map
2. Traverse the map, splicing or, and

db.getCollection('subject_form_statistic1').
    find({$or:
           [
            {$and:[{"study_id":'8a81c08b6c19a1ab016c6b49455a54ef'},{"environmentId":'9cddc3aec3444e5db22dd5937f61999a'},{"subject_subject_no":'91'}]}
           ]
         },{ subject_id: 1, environmentId: 1 }).limit(1)

Guess you like

Origin blog.csdn.net/kunAUGUST/article/details/118419812