为什么只用mongoose更新一个数据

时间:2016-12-07 18:37:10

标签: mongoose

我有以下更新声明,我确信UserModel.update({_id: {$in: ids}}, { $addToSet: { goods: goodsid }}, callback); 有多个数据,但只更新一个数据。

任何人都可以帮助为什么会这样?

string s;
string[] s_list;

// Your logic that would generate s and store it in s_list
// ...
// ...

int required_amount = 10; // whatever X amount you want
int current_sequence = 0;

// It's important to start at 1, and not 0,
// as you compare to the previous entry each time
for(int i = 1; i < s_list.Lenght; i++ )
{
   if( s_list[i] == s_list[i-1] )
   {
     current_sequence++;
     if(current_sequence >= required_amount)
     {
       return 1;
     }
   }
   else
   {
     current_sequence = 0;
   }
}

1 个答案:

答案 0 :(得分:0)

您需要发送带有更新选项的第三个参数:

$("video").each(function() { $(this).get(0).pause(); });

请参阅: https://docs.mongodb.com/manual/tutorial/update-documents/

http://mongoosejs.com/docs/api.html#model_Model.update