i've 2 collections, named user-profile
from database user-service
and user-wishlist
from database pcrf-service
.
is it possible to do $lookup function in mongodb from another database?
i've used this: db.getSiblingDB('dbname').collection.command()
but it's not working.
here's my code:
db = db.getSiblingDB("user-service");
db.getCollection("user-profile").aggregate(
[
{
"$sort" : {
"createdOn" : -1.0
}
},
{
"$lookup" : {
"from" : "pcrf-service.user-wishlist",
"localField" : "mobile",
"foreignField" : "userId",
"as" : "contents"
}
}
],
{
"allowDiskUse" : false
}
);