Search code examples
sqlorientdbnosql

How to migrate from a String property to a Link in OrientDB?


I have a Class in OrientDB, which is called Book. The book has an author property, which is of type String, which contains the author name. I also have an Author class, with the same names for the author, but now I want to connect these two classes.

In short, I want to migrate the author property to a LINK reference, to the Author class, which has a name, bio, etc.

So I need to migrate my Book, but how do I do this without losing my data?


Solution

  • You could also execute something like (I din't try it):

    update Book set author2 = (select from Author where name = $parent.current.author )
    update Book set author = author2
    update Book remove author2