使用Doctrine MongoDB ODM的Symfony2项目:
我有以下文件:
用户
referenceOne:
my_buddy:
targetDocument: Buddiness #(just an example)
mappedBy: from_user
simple: true
buddy_with_me:
targetDocument: Buddiness
mappedBy: to_user
simple: true
Buddiness
referenceOne:
from_user:
targetDocument: User
simple: true
inversedBy: my_buddy
to_user:
targetDocument: User
simple: true
inversedBy: buddy_with_me
在每个经过身份验证的请求中,我有2个额外的查询:
db.Buddiness.find({ "from_user": ObjectId("...") }).sort([ ]).limit(1).limit();
db.Buddiness.find({ "to_user": ObjectId("...") }).sort([ ]).limit(1).limit();
我怎样才能摆脱这些2?