I’m working on a system deals with dynamic properties.
If I want to create a vertex, I can do it like this before that:
select * from ag_catalog.cypher('people',$$ create (nyk:person{name:'nyk'}) return nyk $$) as (v ag_catalog.agtype);
But now, I don’t know the property, the property is given by the user as a json object.
The property may be {name:'asdf'}
or {name:'asdf', age:25}
or {name:'asdf', work:'programmer'} ....
I don’t know what property will get.
The problem is same when using the delete,update or get method.
So how to deal with that? Can I bind the property with a json parameter?
2
Answers
You can later use the SET clause to insert the properties. Assuming that
{name: 'John Doe'}
is the JSON provided by the user, the following code demonstrates its usage:If you intend to incorporate user input, you’ll need to use one of the drivers available for AGE, such as the Python driver.
You can use any driver support to read the data from the user and then assign that read data according to the properties.
You can view different driver support here at github.
Once the data is read then it can be stored accordingly.
like below