Setting record fields to the same value as the primary_id

For one of my vertex type, I want one of my fields to be same as the primary_id. I tried this:

CREATE QUERY populate_id_fields() FOR GRAPH oc {
S = {entity.*};

UPDATE s FROM S:s
SET s.activerecord_id = str_to_int(s.id);

}

but it’s giving me an error "primary_id not usable in the query body. Is there a workaround for this? Thank you.

Hi Ivan,

Thanks for your question.

It is not allowed directly use s.id without setting primary_id_as_attribute.

To enable that you can

  1. create that vertex by using the config: WITH primary_id_as_attribute=“true”
  1. Check the checkbox in GraphStudio

Check as attribute when defining the vertex in Schema Design page.

image.png

Please be noted, either way, the system will remove the data of that vertex (including edges connected to that vertex) being changed.

Thanks.