Nested Data

If you need to synchronize more complex data that may also contain other data within it, Asyncher can handle it.

For example, if your data has attributes (id, name, surname, comments), the JSON sent by the client will be of this type:

{
    "id": 0,
    "name": "test_name",
    "surmame": "test_surname",
    "comments": [
        {
            "id": 0,
            "content": "My first comment",
            "is_new": false,
            "updated": false,
            "deleted": false
        },
        {
            "id": 1,
            "content": "My second comment",
            "is_new": false,
            "updated": false,
            "deleted": false
        }
    ],
    "is_new": false,
    "updated": false,
    "deleted": false
}

As you can see you will simply have to pass it the comments too and Asyncher will automatically understand that it will have to synchronize them too. Note that the comments also include the is_new, updated and deleted attributes.


If you need it, you do not necessarily have to pass it a list, Asyncher also accepts just an object. For example:

{
    "id": 0,
    "name": "test_name",
    "surmame": "test_surname",
    "address": {
        "city": "XXXXXXX",
        "postal_code": "XXXXXXX",
        "is_new": false,
        "updated": false,
        "deleted": false
    },
    "is_new": false,
    "updated": false,
    "deleted": false
}

If you are aware of the fact that your data could start to be really complex and numerous, you can always consider separating them, that is, using an instance of Asyncher that synchronizes one data and another instance that synchronizes another data.

Last updated