【问题标题】:How to add and remove a link from link list in OrientDB using OrientJS APIs如何使用 OrientJS API 在 OrientDB 的链接列表中添加和删除链接
【发布时间】:2016-09-04 18:35:46
【问题描述】:

在我的 Orient 数据库中,我创建了两个类 mainsub。这些类的属性如下。

主要

  • 名称(字符串)
  • 描述(字符串)
  • 孩子(链接列表)

  • 名称(字符串)
  • 描述(字符串)

我正在使用节点应用程序来更新此数据库上的数据。我想要做的是将记录添加到类Sub 并将它的@rid 添加到Mainchild 现有记录的链接列表。对于插入,我使用下面的代码。

database
  .insert().into('Sub')
  .set(values)
  .one()
  .then(function (data) {})

但我正在努力使用 OrientJS API 将 data['@rid'] 添加到 Mainchild 链接列表。我试过了

database
  .insert().into('Sub')
  .set(values)
  .one()
  .then(function (data) {
      database.update('Main')
      .set({child:data['@rid']})
      .where('#01:0')
      .one();
  });

但这没有用。如果我使用查询添加此链接,如下所示,

update #01:0 add children = #02:0

如何在不使用查询的情况下使用 OrientJS 将链接添加到链接列表

db.query('update #01:0 add children = #02:0');

【问题讨论】:

  • 使用查询有什么问题?你也可以试试这个:CREATE LINK <link> TYPE [<link-type>] FROM <source-class>.<source-property> TO <destination-class>.<destination-property>

标签: node.js orientdb orientjs


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    相关资源
    最近更新 更多