I'm new to OrientDB and I'm developing a test application for internal use (orientdb 2.2.17).
I'm trying to add a new document to class with a subquery as one of the values.
Classes:
CREATE CLASS Website
CREATE PROPERTY Website.id String
CREATE PROPERTY Website.name String
CREATE PROPERTY Website.created DateTime
CREATE CLASS User
CREATE PROPERTY UserEndpoint.id String
CREATE PROPERTY UserEndpoint.website String
CREATE PROPERTY UserEndpoint.created DateTime
I'm trying to add a new user with a reference to some website.
For example:
INSERT INTO Website (name) VALUES ('localhost:8090')
And after that to add user:
INSERT INTO User (website) VALUES (SELECT id FROM Website WHERE )
OR
INSERT INTO User (website) VALUES (SELECT @rid FROM Website WHERE )
The results are not what I'm expecting, the User.website parameter is a string that represents an array, instead of a string that represents a single value.
{
"result": [
{
"@type": "d",
"@rid": "#30:0",
"@version": 1,
"@class": "User",
"created": "2017-12-28T16:35:31",
"id": "a9816adc-8808-4673-b5a7-b11493b0ce36",
"website": "[Website#25:0{created:Thu Dec 28 16:34:25 UTC 2017,id:e0ce0e68-003b-4a01-8c4f-856d9eeb6125,name:localhost:56} v1]"
}
]
"notification": "..." }
Expected:
{
"result": [
{
"@type": "d",
"@rid": "#30:0",
"@version": 1,
"@class": "User",
"created": "2017-12-28T16:35:31",
"id": "a9816adc-8808-4673-b5a7-b11493b0ce36",
"website": "#25:0"
}
]
"notification": "..." }
And I also want to make a relationship between website and users (user belong to one website and website might have a lot of users), is this is the right way:
CREATE LINK websiteUsers TYPE LINKSET FROM User.website TO Website.rid
?
And while I query for a user and I want to get website details, did the add automatically to result?