Neptune DB doesn't change property value to the previous value

Viewed 182

I have very weird issue with AWS Neptune DB. I can only change property to new value and can't use any of previous names.
I'm using gremlin and node.js.
That sounds so weird so let me to add some code:

  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);

So I think I should have response like:

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

but I have:

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

Interesting thing, if I'm using any single word (without spaces) instead of bar foo I have proper result. And I have the same issue when I query database not one after another. Did someone saw such problem? Do you know how to solve it?

1 Answers

Neptune by default uses Set cardinality. Each time you add a value you are expanding that Set as you are not explicitly using Cardinality.single. Moreover, elementMap will only return one element of a Set cardinality property. To see them all use valueMap instead.

Related