values vs name/id

The shortcut:

"/music/artist/active_start": [{}]

The explanation:

There's a bit of a trick to this. MQL divides the world into "values"
and "objects". If you look at the expected_type of a property (try the query

{ "query0":
{ "query":
{ "id": "",
"type": "/type/property",
"expected_type": null
}
}
}

You will find out if a property expects a value (one of /type/id, /type/key, /type/text, /type/rawstring, /type/int, /type/float, /type/boolean and /type/uri) or an object (anything else)

Then you can ask

[{ "name": null, "id": null, "type": [], "optional": true }]

for the objects and

[{ "value": null, "type": null, "optional": true }]

for the values. (the optional: true ensures the query doesn't fail if the property is missing)

[{}] asks MQL to automatically inspect the expected_type for you and insert one or other of the clauses you see above, depending on which is appropriate. It's what we use internally 90% of the time.

More information on how to query schema objects, their properties, user interaction with those objects, and the links between them can be found in the Schema Introspection Cookbook.

Search Help Center

Discussions

There are no conversations on this topic. Would you like to start one?

Start the Discussion »