【问题标题】:Error when creating a record with linklist using OrientJS使用 OrientJS 使用链接列表创建记录时出错
【发布时间】:2017-03-15 14:10:08
【问题描述】:

我正在尝试使用 NodeJS 服务器上的 OrientJS 框架将对象保存到数据库中。 此对象包含一些本机参数以及应该指向另一个类的记录的 RID 数组。看到这个:

var myObj = {
   name: 'myNewObjectName',
   '@class': 'OuterClass',
   parameter: ['#225:13']
}

在 OrientDB 类中,“参数”字段定义为 LINKLIST。但是,当我尝试为此对象创建新记录时:

db.record.create(myObj).then(function(record){
   console.log(record);
});

我得到了例外:

Unhandled rejection OrientDB.RequestError: For input string: "#225" at child.Operation.parseError (C:\Users\...\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:864:13)
at child.Operation.consume (C:\Users\...\node_modules\orientjs\lib\transport\binary\protocol33\operation.js:455:35)
at Connection.process (C:\Users\...\node_modules\orientjs\lib\transport\binary\connection.js:399:17)
at Connection.handleSocketData (C:\Users\...\node_modules\orientjs\lib\transport\binary\connection.js:290:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)

那么不知何故,Cluster 后面的 ID 没有通过?我做错了什么,还是这是一个错误?我还能做什么?

非常感谢您的帮助!

【问题讨论】:

    标签: javascript angularjs node.js orientdb orientjs


    【解决方案1】:

    您应该使用 RID 对象来插入链接。试试这个。

    const RID = require('orientjs').RID;
    .....
    var myObj = {
       name: 'myNewObjectName',
       '@class': 'OuterClass',
       parameter: [new RID('#225:13')]
    }
    

    【讨论】:

    • 嗨 wolf4food。非常感谢您的回答!我找到了一种解决方法,现在将我从 orientDB 检索到的嵌套 RID 保存在一个专用变量中。这样,它就不会弄乱任何 RID 字符串。所以我没有完全使用你的方法,但我认为你指出的问题仍然是我的问题的原因。万一其他人遇到这种问题,您的建议可能就是解决方案。干杯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-01
    • 1970-01-01
    相关资源
    最近更新 更多