1

我有关注者和订阅者项目,当用户关注其他用户时,我应该增加 1 到关注者和增加 1 到订阅者的数量

我使用这些代码来更新,

这个k是追随者的计数,

$m->obarax->user->update(array("_id" => $_SESSION["u"]["_id"]),array('$inc' => array("k" => (int)1)));

t是订阅者的数量,

$m->obarax->uye->update(array("_id" => new MongoId($_GET["idi"])),array('$inc' => array("t" => (int)1)));

困扰我的事情是,我搜索了很多,但我找不到将这两个查询合并为一个基本查询的方法,有没有办法可以合并这些查询?谢谢你 :)

4

1 回答 1

0

You can't merge them since you're updating two different keys on two different documents. Besides that, your collections also differ, but it still not possible even if you were using the same collection because your data will be de-normalized in this case.

于 2013-05-28T13:03:10.280 回答