使用OrientJS创建包含链接列表的记录时出错

时间:2017-03-15 14:10:09

标签: javascript angularjs node.js orientdb orientjs

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

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

在OrientDB类中,“parameter”-field被定义为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)

所以不知道集群后面的ID是不是通过了?我做错了什么,或者这是一个错误?我还能做什么?

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

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

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