Property Access

The Medable API affords developers the ability to access and update property data in flexible and convenient ways.

Although Property Selection can reduce the number of paths returned while maintaining the structure of the document. One way to do it

// GET /accounts/5516ee2634d8d93428169c0e?paths[]=name.first

{
    "_id": "5516ee2634d8d93428169c0e",
    "name": {
        "first": "Jonas"
    },
    "object": "account"
}

A single property can also be directly accessed, resulting in a result response.

Even Simpler

// GET /accounts/5516ee2634d8d93428169c0e/name/first

{
    "object": "result",
    "data": "Sarah Jones"
}

A property within a document array can be directly accessed, using its _id ("551f34c8b8b206e835950b57"). For example, retrieving the name of a custom role:

// GET /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57/name

{
    "object": "result",
    "data": "Care Giver"
}

Properties may be updated in the same way. The following are both valid ways to update the name of the above role:

// PUT /orgs/5516ee1b34d8d934281699e3

Request:
    {
        "roles": [{
            "_id": "551f34c8b8b206e835950b57",
            "name": "Third Party"
        }]
    }
Response:
    {
        "_id": "5516ee1b34d8d934281699e3",
        "object": "org",        
        "code": "example",        
        "roles": [{
            "_id": "551f3515b8b206e835950b59",
            "name": "Care Giver",
            "all": [],
            "include": []            
            },
            ...
        ],
        ...                
    }

The above response includes the entire updated context.

// PUT /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57/name

Request:
    "Third Party"
Response:
    {
        "object": "result",
        "data": "Third Party"
    }

Property and Document arrays can be configured to allow overwrite, append-only, and/or pull. Arrays can also be configured to ensure unique values within the array, or in the case of a Document array, a property can have a validator that ensures it is unique within the rest of the parent array's documents.

  • Appending items to an array using the API must be done using the POST method.

  • Overwriting an array is done using PUT.

  • Array elements can be directly access by index (GET /orgs/5516ee1b34d8d934281699e3/roles/0).

  • Array elements cannot be updated by index.

  • When removing elements from a document array, use the _id (DELETE /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57)

  • When removing elements from a primitive array, all matching values are removed (DELETE /c_custom/c_tags/MyTag)

Last updated