1
votes

In OrientDB, I have a class "V_MyClass", and a property of type "link" to the class V_User ("createdBy"). Both extend V. In this moment, I have a query which returns all elements from class.

select from MyClass

"createdBy" is something like "#1:11". V_User has a property like "username". I want to add "username" for "createdBy", in this select.

The SQL version is: - current query:

select * from MyClass

- requested query:

select m.*, u.username from myclass m inner join user u on m.createdBy = u.id

I want to reproduce the same query in OrientDB. Note that createdBy is not an edge, but a "link" property.

2
I do not know if I understand correctly, then would you create the username property on the link? - Alessandro Rota
I don't want to create the username. In SQL standard, the query is something like "select u.username, m.* from my_class m inner join user u on [...]" I want only to extract username from V_User in the select. - Catalin Vladu
I edited my question. - Catalin Vladu

2 Answers

4
votes

You could use this query

select *,createdBy.username from V_MyClass

Hope it helps.

0
votes

If you want to add properties to the relationship you will need to do an update (it is not a normal query). If you do a "selec...from...where..." you won't update.

Try with this (you can see more info in the doc):

UPDATE <class>|cluster:<cluster>|<recordID>
[SET|INCREMENT|ADD|REMOVE|PUT <field-name> = <field-value>[,]*]|[CONTENT|MERGE <JSON>]
[UPSERT]
[RETURN <returning> [<returning-expression>]]
[WHERE <conditions>]
[LOCK default|record]
[LIMIT <max-records>] [TIMEOUT <timeout>]