'Drag and drop with express and mongoose

I have a linktree clone project where you can build your portofolio from multiple urls. At the moment, the links are in a chronological order (when they were put in the database). I want to be able to modify their order but don't know what is the best aproach or where to start. The only thing that I could think of was an array stored in Page Schema with the orders of id urls(named pageLayout). I'm a beginner and still learning

The JSON generated is something like this:

{
"theme": "white",
"banner": "uploads/banners/default.png",
"avatar": "uploads/avatars/default.png",
"pageLayout": [],
"_id": "62825469a716308778488106",
"urlName": "test",
"title": "TEST",
"description": "TEST PAGE",
"category": "Photography",
"socialMedia": {
    "Instagram": "test",
    "Twitter": "test.twitter",
    "Tiktok": "test.tiktok"
},
"__v": 0,
"blocks": [
    {
        "blockType": "links",
        "_id": "628a646534a2f89b190bb309",
        "title": "Learn Blockchain1",
        "user": "628172dff7334877a4ecf19e",
        "pageId": "62825469a716308778488106",
        "__v": 0,
        "links": [
            {
                "display": true,
                "thumbnail": "uploads/linkThumbnails/default.png",
                "_id": "628a732533d84c9cf988993b",
                "blockId": "628a646534a2f89b190bb309",
                "title": "First Project1",
                "url": "www.test.com/ethkasbdj",
                "user": "628172dff7334877a4ecf19e",
                "__v": 0
            },{
                "display": true,
                "thumbnail": "uploads/linkThumbnails/default.png",
                "_id": "628a732533d84c9cf988993b",
                "blockId": "628a646534a2f89b190bb309",
                "title": "First Project2",
                "url": "www.test.com/ethkasbdj",
                "user": "628172dff7334877a4ecf19e",
                "__v": 0
            }
        ],
        "id": "628a646534a2f89b190bb309"
    }
],
"id": "62825469a716308778488106"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source