Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > db.properties.findOne({'agentid':'mike@gmail.com'},{'agentid':1,'contact':1})
- {
- "_id" : ObjectId("56d2cc296f07d417008b4567"),
- "agentid" : "mike@gmail.com",
- "contact" : [
- {
- "type" : "listingAgent",
- "id" : "1",
- "name" : "Mike",
- "telephoneType" : "",
- "telephone" : "",
- "email" : "mike@gmail.com"
- }
- ]
- }
- > db.agents.findOne({'email':'mike@gmail.com'})
- {
- "_id" : ObjectId("5979d1400045fecc0800004c"),
- "id" : "35",
- "agentID" : "mike@gmail.com",
- "email" : "mike@gmail.com",
- "name" : "Mike",
- "telephone" : "",
- "status" : true
- }
- > db.users.findOne({'email':'mike@gmail.com'})
- {
- "_id" : ObjectId("5979d0e20045feac0d00003f"),
- "id" : "20",
- "email" : "mike@gmail.com",
- "type" : "publisher",
- "status" : "inactive",
- }
- $query =
- array(
- array('$lookup'=>array(
- 'from'=>'agents`',
- 'localField'=>'email',
- 'foreignField'=>'email',
- 'as'=>'users_agents'
- )
- ),
- array('$unwind'=>'$properties.contact'),
- array('$lookup'=>array(
- 'from'=>'properties',
- 'localField'=>'email',
- 'foreignField'=>'contact.email',
- 'as'=>'users_properties'
- )
- ),
- array('$match'=>array(
- '$and'=>array(array('users_properties.offline'=>false),
- array('users_agents.status'=>true)))),
- array('$project'=>array(
- '_id'=>1,
- 'id'=>1,
- 'username'=>1,
- 'firstname'=>1,
- 'lastname'=>1,
- 'email'=>1,
- 'type'=>1,
- 'status'=>1,
- )
- ),
- );
- $collection_users->aggregate ($query );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement