After googling a bit more I ended up finding this
<http://www.orientdb.org/releases/latest/javadoc/com/orientechnologies/orient/core/record/ORecord.html#toJSON()>
and realised how to achieve what I was looking for. To get the rids i's
just a matter of adding 'rid' to toJson(). So the solution is:
select @this.toJSON('rid,fetchPlan:roles:1') from OUser where name='admin'
{
"@type": "d",
"@rid": "#-2:1",
"@version": 0,
"this":
"{\"@rid\":\"#5:0\",\"name\":\"admin\",\"password\":\"{SHA-256}8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918\",\"status\":\"ACTIVE\",\"roles\":[{\"@rid\":\"#4:0\",\"name\":\"admin\",\"inheritedRole\":null,\"mode\":1,\"rules\":{\"database.bypassrestricted\":15}}]}"
}
Which contains the RIDs.
Thanks for the help Jonathan.
On Monday, 10 November 2014 22:21:21 UTC, Dário Marcelino wrote:
>
> Hey Jonathan,
>
> I appreciate the effort but I'm afraid that query only returns the roles
> (linked records) and not the user (parent record), result below. The
> objective is to get the parent and the linked records with the latter
> having their @rid included. My original query, select @this.toJSON(
> 'fetchPlan:roles:1') from OUser where name='admin', is very close to it
> but the linked records come without @rid. Let me know if this is not clear.
> I'm also trying to avoid running more than one query for performance
> reasons.
>
> {
> "@type": "d",
> "@rid": "#4:0",
> "@version": 2,
> "@class": "ORole",
> "name": "admin",
> "inheritedRole": null,
> "mode": 1,
> "rules": {
> "database.bypassrestricted": 15
> },
> "@fieldTypes": "mode=b"
> }
>
>
>
>
> On Monday, 10 November 2014 21:28:29 UTC, Jonathan Rosen wrote:
>>
>> What about this?
>>
>> select expand(roles) from OUser where name='admin'
>>
>> On Mon, Nov 10, 2014 at 4:16 PM, Dário Marcelino <[email protected]>
>> wrote:
>>
>>> Sorry for bumping this up but does anyone have any ideas on how to
>>> achieve this? Or OrientDB does not support returning the @rid of
>>> linked/child records in a FetchPlan? If it's the latter case I guess it
>>> would be a nice feature to have as having the @rid is useful in
>>> updates/deletions, for example.
>>>
>>> Thanks
>>>
>>>
>>> On Tuesday, 4 November 2014 10:22:53 UTC, Dário Marcelino wrote:
>>>>
>>>> Hi Jonathan,
>>>>
>>>> That does include the parent row RID (#5:0) but not the child row ID
>>>> (#4:0) which is what I'm after:
>>>>
>>>> {
>>>> "@type": "d",
>>>> "@rid": "#-2:1",
>>>> "@version": 0,
>>>> "rid": "#5:0",
>>>> "this": "{\"name\":\"admin\",\"password\":\"{SHA-256}
>>>> 8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448
>>>> A918\",\"status\":\"ACTIVE\",\"roles\":[{\"name\":\"admin\",
>>>> \"inheritedRole\":null,\"mode\":1,\"rules\":{\"database.
>>>> bypassrestricted\":15}}]}"
>>>> }
>>>>
>>>>
>>>>
>>>> On Tuesday, 4 November 2014 02:17:08 UTC, Jonathan Rosen wrote:
>>>>>
>>>>> select @rid, @this.toJSON('fetchPlan:roles:1') from OUser where name=
>>>>> 'admin'
>>>>>
>>>>> Does that work for you?
>>>>>
>>>>> On Monday, November 3, 2014 12:40:18 PM UTC-5, Dário Marcelino wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I've noticed that when I do a query using a fetch plan, the linked
>>>>>> records do not contain their ID. For example, taking the demo database
>>>>>> of
>>>>>> 1.7.1:
>>>>>> select @this.toJSON('fetchPlan:roles:1') from OUser where name=
>>>>>> 'admin'
>>>>>>
>>>>>> Returns:
>>>>>> {
>>>>>> "result": [
>>>>>> {
>>>>>> "@type": "d",
>>>>>> "@rid": "#-2:1",
>>>>>> "@version": 0,
>>>>>> "this": "{\"name\":\"admin\",\"password\":\"{SHA-256}
>>>>>> 8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448
>>>>>> A918\",\"status\":\"ACTIVE\",\"roles\":[{\"name\":\"admin\",
>>>>>> \"inheritedRole\":null,\"mode\":1,\"rules\":{\"database.
>>>>>> bypassrestricted\":15}}]}"
>>>>>> }
>>>>>> ],
>>>>>> "notification": "Query executed in 0.057 sec. Returned 1
>>>>>> record(s)"
>>>>>> }
>>>>>>
>>>>>> which does not include the ID of the admin role (#4:0).
>>>>>>
>>>>>> Is there anyway to populate the IDs of linked records?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "OrientDB" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/orient-database/QPhLb5MJI6s/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.