Hi, now I am trying to do the standard "read", "update" "delete" operations
on the fields of my Employee Vertex via the function manager in javascript
and unfortunately every method I tried except the "getIdentity()" doesn't
seem to be available...
example:
var gdb = orient.getGraph();
var employees = gdb.command('sql', 'select * from Employee', []);
var emp = employees[0];
//emp
//[
// {
// "@type": "d",
// "@rid": "#12:72",
// "@version": 8,
// "@class": "Employee",
// "nom": "Test",
// "prenom": "Brett",
// "out_employee_belong_departement": [
// "#13:11"
// ],
// "@fieldTypes": "out_employee_belong_departement=g"
// }
//]
return emp.field('nom');
Error
Erroronparsingscriptatposition#0: ErroronexecutionofthescriptScript:
myFunction------^TypeError: v(Employee)[
#12: 72
]hasnosuchfunction"field"in<eval>atlinenumber57TypeError: v(Employee)[
#12: 72
]hasnosuchfunction"field"
Is this a bug ?
On Friday, 24 October 2014 09:09:39 UTC+11, Brett Coffin wrote:
>
> It works! Thanks
>
>
>
> On Friday, 24 October 2014 08:52:59 UTC+11, Lvc@ wrote:
>>
>> Hi,
>> employees contains ODocument objects, so to extract fields you should use
>> .field() method. To get the identity ODocument has .getIdentity() method.
>> Example:
>>
>> var e = "create edge employee_belong_dpartement from #" +
>> emp.getIdentity() + " to " + department.getIdentity();
>>
>>
>> Lvc@
>>
>>
>> On 23 October 2014 16:46, Brett Coffin <[email protected]> wrote:
>>
>>> I am trying to generate some mock data via a function, basically some
>>> edges between a "Department" and "Employee" Vertex.
>>>
>>> Here is the code:
>>>
>>> var employees = gdb.command('sql', 'select * from Employee', []);
>>> var departments = gdb.command('sql', 'select * from Department', []);
>>>
>>> for (var i = 0; i < employees.length; i++) {
>>> var emp = employees[i];
>>> var department =
>>> departements[Math.round(Math.random()*(departements.length - 1))];
>>> var e = "create edge employee_belong_dpartement from #" +
>>> emp['@rid'] + " to " + department['@rid'];
>>> gdb.command('sql',e, []);
>>> }
>>>
>>> gdb.commit();
>>>
>>>
>>> When I log emp['@rid'] I get nothing back, I can't seem to read the
>>> "id" or any other value.
>>> Please help me understand what is going on in the console as its hard to
>>> debug thanks
>>>
>>>
>>>
>>> --
>>>
>>> ---
>>> 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.
>>>
>>
>>
--
---
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.