Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Check transaction response with velocypack #39

Open
sandrokeil opened this issue Dec 5, 2017 · 2 comments
Open

Check transaction response with velocypack #39

sandrokeil opened this issue Dec 5, 2017 · 2 comments

Comments

@sandrokeil
Copy link
Owner

We should find a possibility to replace the Type inspectors with working directly on velocypack data for faster checks. This is especially needed for lager transactions/responses.

Succesful response

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAf0iN----"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAf0iN---_"
            }
        ]
    }
}

Error response single type

Attention: Root error key is false, but individual result has "error": true,.

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAg_9aK---"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAg_9aK--_"
            },
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            }
        ]
    }
}

Error response multiple types

Attention: Root error key is false, but individual result has "error": true,.

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": [
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000001",
                "_key": "100000000000000001",
                "_rev": "_WAgC_wq---"
            },
            {
                "_id": "c878c0b7e51ecaab95c511fc816ad2a70c9418208/100000000000000002",
                "_key": "100000000000000002",
                "_rev": "_WAgC_wq--_"
            }
        ],
        "rId1": [
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            },
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            }
        ]
    }
}

I would suggest to only find the first error object and transform it to an exception. A method to get all errors would be nice too. The error object under result has the following structure:

{
    "error": true,
    "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
    "errorNum": 1210
}

Would be nice if there is a faster lookup instead of iterating through each result.

@sandrokeil
Copy link
Owner Author

We should add the silent option for InsertDocument calls, because this simplifies error check. rId0 has the value true. 🎉

{
    "code": 200,
    "error": false,
    "result": {
        "rId0": true,
        "rId1": [
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            },
            {
                "error": true,
                "errorMessage": "unique constraint violated - in index 0 of type primary over [\"_key\"]",
                "errorNum": 1210
            }
        ]
    }
}

@sandrokeil
Copy link
Owner Author

We get fast access with Working with Arrays and Objects.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant