Sha256: a0bb3260e7905a6935c0ba2ffd288a5832bccf2c05d8bc6374688e8c7ed06794

Contents?: true

Size: 824 Bytes

Versions: 14

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

module Grumlin::Shortcuts::Upserts
  extend Grumlin::Shortcuts

  shortcut :upsertV do |label, id, create_properties = {}, update_properties = {}|
    self.V(id)
        .fold
        .coalesce(
          __.unfold,
          __.addV(label).props(Cardinality.single, **create_properties.merge(T.id => id))
        ).props(Cardinality.single, **update_properties)
  end

  shortcut :upsertE do |label, from, to, create_properties = {}, update_properties = {}|
    id = create_properties[T.id] || Grumlin.fake_uuid(from, label, to)
    self.V(from)
        .outE(label).where(__.inV.hasId(to))
        .fold
        .coalesce(
          __.unfold,
          __.addE(label).from(__.V(from)).to(__.V(to)).props(**create_properties.merge(T.id => id))
        ).props(**update_properties)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
grumlin-1.2.0 lib/grumlin/shortcuts/upserts.rb
grumlin-1.1.0 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.4 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.3 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.3.beta1 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.2 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.1 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc7 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc6 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc5 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc4 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc3 lib/grumlin/shortcuts/upserts.rb
grumlin-1.0.0.rc2 lib/grumlin/shortcuts/upserts.rb