invalid data type for properties

Hi,

I’m just playing around at the moment, whilst looking for a cloud DB with REST API and server code. So far, you’re looking good?

However, I’ve set up two tables: Clients and Tags

Clients is returning the following data on an unfiltered GET request:



{
    "offset": 0,
    "data": [
        {
            "wp_id": 1,
            "crm_id": "456",
            "billing_id": "123",
            "created": 1457214390000,
            "___class": "Clients",
            "ownerId": null,
            "updated": null,
            "objectId": "67F12CEB-AE48-BFD9-FFFD-1A9A7D036900",
            "__meta": "{\"relationRemovalIds\":{},\"selectedProperties\":[\"wp_id\",\"crm_id\",\"billing_id\",\"created\",\"___class\",\"ownerId\",\"updated\",\"objectId\"],\"relatedObjects\":{}}"
        }
    ],
    "nextPage": null,
    "totalObjects": 1
}

And tags is set up with a relationship from the tag to the client (one client to many tags).

So, by reckoning, if I want to create a tag for that client, I need to use the relationship field in the tag and assign it the object id of the client, using:

POST

{
"title": "Customers",
"client_id": "67F12CEB-AE48-BFD9-FFFD-1A9A7D036900"
}

However, this is returning the error:

{
    "code": 1007,
    "message": "Unable to save object - invalid data type for properties - client_id. You can change the property type in developer console."
}

Attached is the tags schema screenshot.

Any ideas what I’m doing wrong?

Regards,
Andy

Picture.png

Hi Andy,

Try it like this:

{
"title": "Customers",
"client_id": {  "___class":"Clients", "objectId":"67F12CEB-AE48-BFD9-FFFD-1A9A7D036900" }
}

Please let me know if that works.

Regards,
Mark

Sorted! Thanks Mark. I’ve not used nosql databases before, so this is a bit of a learning curve for me. Is that a MongoDB thing? I’ve not come across it when I looked up how to do references.

Regards,
Andy

Hi Andy,

This is more of a “backendless thing” )) The rationale is: “client_id” is a relation property, which means it contains an object (or a collection of objects in case of one-to-many). To reference a related object all you need is it’s objectId and the name of the table where it resides (identified by the ___class property).

Hope this helps.

Regards,
Mark

OK, thanks for clarifying Mark.