<https://lh3.googleusercontent.com/-5rtacOPQV5E/VWw68ZMWOWI/AAAAAAAAABE/CqKdIMOHi_c/s1600/scuola.jpg>
Hi Ropel,
try this function, should be the solution you are looking for.
First you should create a User class with name, nameschool
and then paste this code into functions tab and choose how javascript.
Give a name to the function, save and run it.
*1 question (using the function):*
var gdb = orient.getGraphNoTx();
gdb.command( "sql", "create property User.Name2 String");
gdb.command( "sql", "update User set Name2='' ");
should create you for every user the property name2 (to see: select from
User)
*2 question (using the function)*
var gdb = orient.getGraphNoTx();
var node = gdb.command( "sql", "SELECT FROM User");
gdb.command( "sql", "create class School extends V");
gdb.command("sql", "create class link_to_school extends E");
gdb.command( "sql", "create property School.nameschool String");
var listschool = gdb.command( "sql", "select distinct(nameschool) as
nameschool from User");
var name;
for(i=0; i<listschool.length; i++) {
name = listschool[i].getProperty("nameschool");
gdb.command( "sql", "insert into School (nameschool) values('"+name+"')");
}
var rid_user;
var school_user;
for(i=0; i<node.length; i++) {
rid_user = node[i].getId().toString()+"";
school_user = node[i].getProperty("nameschool");
gdb.command( "sql", "create edge link_to_school from " +rid_user+ " to
(select from School where nameschool = '"+school_user+"')" );
}
It should create you for every user who has the name of the school, a link
between user and school
example view image above.
reguards
Luigi S.
Il giorno lunedì 1 giugno 2015 02:00:47 UTC+2, [email protected] ha
scritto:
>
> I imported a lot of data in a pretty messy format thinking it would be
> easy to edit the records later. It hasn't been and I think it's because I'm
> struggling to understand the Orient SQL syntax. I'm using oriento but raw
> queries are fine.
>
>
> General questions that I can't find answers to in the manual:
>
>
> How do I copy a property from another property for all nodes? (e.g. I
> have a property called “name” and I want to create another identical
> property on the same node with identical data called “name2”, and repeat
> this on every node).
>
>
> I also want to create nodes from the properties of another node. (e.g. I
> have a node “Person” which has a property “school” and I want to create a
> node for each school and then a link from the person to the school).
>
>
> Thanks for your help.
>
--
---
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.