Query the list of built-in objects

I have an element endpoint that contains a list of inline images. The scheme looks like this:

_schema = { 'name': required_string, # group name 'description': { 'type': 'string', 'maxlength': 140, }, 'images': { 'type': 'list', 'scheme': { 'type': 'objectid', 'data_relation': { 'resource': 'images', 'embeddable': True, 'field': '_id', } }, } } 

So I'm trying to query the endpoint of the elements to get the embedded objects

/ elements / 549ae47f4fb9041305403292 embedded =? {"Images": 1}

But instead of inline images, I get only a regular object with a list of _ids images.

Here is an example object:

 { "_updated": "Wed, 24 Dec 2014 16:06:23 GMT", "name": "New Item", "images": [ "549ae47f4fb904130540328b", "549ae47f4fb904130540328e", "549ae47f4fb9041305403291" ], "_created": "Wed, 24 Dec 2014 16:06:23 GMT", "_id": "549ae47f4fb9041305403292", "_etag": "949e3b731823bb2c08682ba4b6696b86856ef941", "description": "The best item ever" } 

I tried to convert image ids to list into objects, but this does not help. Any ideas why this is not working? Thanks

+5
source share
1 answer

Your schema definition is incorrect. Replace scheme with schema when defining the images list:

 _schema = { 'name': required_string, # group name 'description': { 'type': 'string', 'maxlength': 140, }, 'images': { 'type': 'list', 'schema': { # this was 'scheme' in your def 'type': 'objectid', 'data_relation': { 'resource': 'images', 'embeddable': True, 'field': '_id', } }, } } 

Then it embeds your image list correctly.

+5
source

Source: https://habr.com/ru/post/1209847/


All Articles