Reputation: 159
For a NodeEntity with any property(indexed or not - indexed), I wish to change the data type from Integer to String due to some use-case.
I simply changed the datatype in the defined NodeEntity class. The new data gets inserted into the database successfully with the data type of the property as the newly set(ie.String). However, the data type of the property for the nodes already in the database before this change remain as the old data type(ie Integer).
Is there any way to modify the datatype for all the nodes present in the database?
Upvotes: 3
Views: 3313
Reputation: 39905
Cypher has couple of functions for this:
toInt
: convert a string to a integer/long valuetoFloat
: convert a string to a floating point valuestr
: convert something to a stringWith that you can easily modify the datatypes of existing properties. Assume you have a entity of type Person
having a numeric zipCode
property. You want to convert zipCode
to a string:
MATCH (node:Person)
SET node.zipCode = str(node.zipCode)
If you have a large number of entities of that type make sure your transactions don't grow too large my using SKIP
and LIMIT
.
Upvotes: 5