Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified patch update to separetely process the meta field #319

Merged

Conversation

antoineludeau
Copy link
Member

Context

The "meta" field is currently a JSONB type in the postgreSQL DB. When patching this field, the whole object is updated and we loose the data that was already present.

Enhancement

This PR aims to add a separate process of the meta field from the rest of the entity (address, common toponym or district) during a 'patch'. The meta field is know processed by adding the fields to the one already present in the DB.

Example :
we have a district in the DB with the following data :

{
    "id": "7d40ffcc-57e2-4621-a538-e3ef20b74b8e",
    "labels": [
        {
            "value": "Toulouse",
            "isoCode": "fra"
        }
    ],
    "updateDate": "2023-01-01T00:00:00.000Z",
    "config": null
    "meta": {
        "insee": {
            "cog": "31555"
        }
    }
}

We patch the district with the following body :

{
    "id": "7d40ffcc-57e2-4621-a538-e3ef20b74b8e",
    "meta": {
        "bal": {
            "idRevision": "65491ca60d6ed147e80ef260",
            "dateRevision": "2023-11-06T17:04:38.540Z"
        }
    }
}

The result in the DB would be :

{
    "id": "7d40ffcc-57e2-4621-a538-e3ef20b74b8e",
    "labels": [
        {
            "value": "Toulouse",
            "isoCode": "fra"
        }
    ],
    "updateDate": "2023-01-01T00:00:00.000Z",
    "config": null
    "meta": {
        "insee": {
            "cog": "31555"
        },
        "bal": {
            "idRevision": "65491ca60d6ed147e80ef260",
            "dateRevision": "2023-11-06T17:04:38.540Z"
        }
    }
}

@antoineludeau antoineludeau force-pushed the antoineludeau/patch-separetely-meta-field-from-rest branch from 4a57e13 to 4f001b0 Compare November 16, 2023 12:36
@antoineludeau antoineludeau merged commit 400d7a9 into master Nov 16, 2023
1 check passed
@antoineludeau antoineludeau deleted the antoineludeau/patch-separetely-meta-field-from-rest branch November 16, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BAN-Plateforme][API] : Patch specifique sur les meta
2 participants