我偶然发现了一个我无法理解的问题。
我有一个数据库(理想情况下)填充条目如下:
{id:1,name:"<somename>", value:1}
{id:2,name:"<somename>", value:2}
{id:3,name:"<somename>", value:3}
{id:4,name:"<somename>", value:4}
{id:5,name:"<somename>", value:5}
如果我想增加每个值,从给定值N开始,我知道我可以做。
OBJECT.filter(Task.vaue>=N).update({Task.value:Task.value+1})
然而, 现实是我的数据库看起来像这样:
{id:1,name:"<somename>", value:1}
{id:2,name:"<somename>", value:2}
{id:3,name:"<somename>", value:3}
{id:4,name:"<somename>", value:5}
{id:5,name:"<somename>", value:10}
我想从值N开始,并且仅增加前一个条目的值为M = N-1的值。例如:
在:
{id:1,name:"<somename>", value:1}
{id:2,name:"<somename>", value:2}
{id:3,name:"<somename>", value:3}
{id:4,name:"<somename>", value:5}
{id:5,name:"<somename>", value:10}
N = 1后:
{id:1,name:"<somename>", **value:2**}
{id:2,name:"<somename>", **value:3**}
{id:3,name:"<somename>", **value:4**}
{id:4,name:"<somename>", **value:5**}
{id:5,name:"<somename>", value:10}
或另一个例子:BEFORE
{id:1,name:"<somename>", value:1}
{id:2,name:"<somename>", value:2}
{id:3,name:"<somename>", value:3}
{id:4,name:"<somename>", value:5}
{id:5,name:"<somename>", value:10}
N = 3后:
{id:1,name:"<somename>", value:1}
{id:2,name:"<somename>", value:2}
{id:3,name:"<somename>", **value:4**}
{id:4,name:"<somename>", **value:5**}
{id:5,name:"<somename>", value:10}