Convert property and all values to string inside graph db

Hello.

I have an existing graph database and a property that is a number. I realized after I created the database that I need that as a string. I can fix the code for new inserts but how do I convert, en mass, the existing data?

Thanks.
Rhys

If your data set is small, you might be able to get by with something like:

MATCH (n:Label) 
SET n.property = toString(n.property)

However if your dataset is large and you can't sustain that in a single transaction, then the apoc.periodic.iterate would likely be of use to you. Modify the following. The first argument to the function to limit to exactly the smallest set that you can. The second argument to perform the mutation. The 3rd argument controls the batch size and concurrency of the overall operation.

CALL apoc.periodic.iterate(
  "MATCH (n:Label)
   RETURN n",
  "SET n.property = toString(n.property)"
  {batchSize:1000, iterateList: true, parallel: true, concurrency: 4}
);