简体   繁体   English

使用HTTP API和json在OrientDB中插入嵌入式类型

[英]Using HTTP API and json to insert an embedded type in OrientDB

I have defined a class 'Box' in OrientDB using the schema manager in studio. 我已经在Studio中使用架构管理器在OrientDB中定义了一个“ Box”类。 'Box' has only one element - an embedded class 'Label'. “盒子”只有一个元素-嵌入式类“标签”。

When I use this json to create a label 当我使用此json创建标签时

 {
    "@class": "Label",
        "boxUUID": "azxc",
        "validFrom": 0,
        "validTo": 100
}

in a POST command to 'Label', the insert works. 在“标签”的POST命令中,插入有效。

But when I use it as below in a POST to 'Box' it fails. 但是,当我在“ Box”的POST中按如下方式使用它时,它会失败。

{
    "@class": "Box",
    "Label": {
        "boxUUID": "azxc",
        "validFrom": 0,
        "validTo": 100
    }
}

With the following error message: 出现以下错误消息:

{
  "errors": [
    {
      "reason": 500,
      "content": "com.orientechnologies.orient.core.exception.OValidationException: The field 'Box.Label' has been declared as EMBEDDED but an incompatible type is used. Value: {boxUUID=azxc, validFrom=0, validTo=100}",
      "code": 500
    }
  ]
}

What is the correct format of the json for a class with an embedded class in OrientDB over the HTTP API? 通过HTTP API在OrientDB中具有嵌入式类的类的json的正确格式是什么?

The correct command is: 正确的命令是:

  • Put in the URL: localhost: 2480 / document / "your database name" 输入URL:localhost:2480 / document /“您的数据库名称”
  • Put in json "@" + name embedded class 放入json“ @” +名称嵌入类

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM