1

I am new in OrientDB. I wanted to create Vertex with Graph API. And after creating it I wanted to add some properties (fields) to the Vertex class, like name type of String, pId type integer, salary type of double. But unfortunately I couldn't find information about it in the documentation. Here is what I have done so far.

OrientGraphNoTx graph = new OrientGraphFactory("remote:localhost/people",
        "user", "password").getNoTx();

if (graph.getVertexType("Person") == null) {

    graph.createVertexType("Person");
}

Here is I am just creating Vertex if it not exists.

In SQL it could done like this:

CREATE CLASS Person EXTENDS V;
CREATE PROPERTY Person.name STRING
CREATE PROPERTY Person.pId INTEGER
CREATE PROPERTY Person.salary DOUBLE

But I want to do it by Graph API. There are methods like graph.addVertexProperty() or graph.createVertexProperty().

1 Answer 1

2

This could be done by:

if (graph.getVertexType("Person") == null) {

    graph.createVertexType("Person");

    OrientVertexType person = graph.getVertexType("Person");
    person.createProperty("pId", OType.INTEGER);
    person.createProperty("name", OType.STRING);
    person.createProperty("salary", OType.DOUBLE);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.