【问题标题】:Neptune DB doesn't change property value to the previous valueNeptune DB 不会将属性值更改为之前的值
【发布时间】:2021-11-01 10:54:38
【问题描述】:

我对 AWS Neptune DB 有一个非常奇怪的问题。我只能将属性更改为新值,并且不能使用任何以前的名称。
我正在使用 gremlin 和 node.js。
这听起来很奇怪,所以让我添加一些代码:

  const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
  const dc = new DriverRemoteConnection(process.env.DB_URL, { authenticator, connectOnStartup: false });
  await dc.open();
  const g = gremlin.process.AnonymousTraversalSource.traversal().withRemote(dc);

  await g.V().hasLabel('Wtf').drop().iterate();
  await g.addV('Wtf').property('test', 'foo').iterate()
  await g.V().hasLabel('Wtf').property('test', 'bar foo').iterate();
  await g.V().hasLabel('Wtf').property('test', 'foo').iterate();

  const wtf = await g.V().hasLabel('Wtf').elementMap().toList();
  console.log(wtf);

所以我想我应该有这样的回应:

  Map(3) {
    EnumValue { typeName: 'T', elementName: 'id' } => '7cbdd4d6-9d72-905f-c4b1-0ee9a31db29a',
    EnumValue { typeName: 'T', elementName: 'label' } => 'Wtf',
    'test' => 'foo'
  }

但我有:

  Map(3) {
    EnumValue { typeName: 'T', elementName: 'id' } => '7cbdd4d6-9d72-905f-c4b1-0ee9a31db29a',
    EnumValue { typeName: 'T', elementName: 'label' } => 'Wtf',
    'test' => 'bar foo'
  }

有趣的是,如果我使用任何单个单词(不带空格)而不是 bar foo 我有正确的结果。 当我一个接一个地查询数据库时,我遇到了同样的问题。 有人看到这样的问题吗?你知道怎么解决吗?

【问题讨论】:

    标签: javascript node.js amazon-web-services gremlin amazon-neptune


    【解决方案1】:

    Neptune 默认使用设置基数。每次添加值时,您都在扩展该 Set,因为您没有明确使用 Cardinality.single。此外,elementMap 只会返回 Set 基数属性的一个元素。要查看它们,请改用valueMap

    【讨论】:

    • 哇!感谢您的快速答复!是的,将基数设置为单个作品。
    • 我在本地的 docker 容器中有 JanusGraph,它在本地运行良好,但在服务器上却不行。所以我花了超过 2 个小时试图修复它。我还没有考虑过 DB 中的基数。再次感谢您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多