I have a list of cards with the field "position" to save the index of the new card, starting with: 1,2,3,4,5.
Cards list Docs :
{ "_id" : ObjectId("5e7e117de6f50cbda72ff41a"), "name" : "stark", "position" : 1,"idBoard":555 }
{ "_id" : ObjectId("5e7e117de6f50cbda72ff41b"), "name" : "sinatra", "position" : 2,"idBoard":555 }
{ "_id" : ObjectId("5e7e117de6f50cbda72ff41c"), "name" : "muzan rusbé", "position" : 3,"idBoard":555 }
{ "_id" : ObjectId("5e7e117de6f50cbda72ff41d"), "name" : "shakira", "position" : 4,"idBoard":555 }
{ "_id" : ObjectId("5e7e117de6f50cbda72ff41e"), "name" : "john travolta", "position" : 5,"idBoard":555 }
I want to insert the name stark with position 1 in position 5.
Result :
sinatra - position 1,
muzan - position 2,
shakira - posiiton 3,
john travolta - position 4,
stark - position 5 (new position)
Is there a way to do this? It's like removing a value from the X index and adding in the Z index to an array. I want change the positon of each card.
Edit: IdBoard 555 is the Board ID that each card has been saved to. Api /card/{Board ID 555}/
save the card with idBoard is 555.