mongodb tip-1

mongodb 

模糊查询:

{people_name:{$regex:/杨/}}

 

 

更新返回更新后的数据:

 NewContract.findByIdAndUpdate(id, data, { new: true, select: 'attachment no' }, cb)

 

 

关联查询:

People.findById(people_id)

                .populate({

                    path: 'it_0002',

                    model: 'IT_0002',

                    select: 'address_type_code address'

                })

                .populate({

                    path: 'company',

                    model: 'Company',

                    select: 'company_name nature province_name city_name tell postcode address'

                })

 

 

 

原文地址:https://www.cnblogs.com/xuezizhenchengxuyuan/p/6260400.html