Sha256: 75d020aeeba553163e07ecfd4018eccabe1f3fac0d39caab50e2bd707b890374

Contents?: true

Size: 839 Bytes

Versions: 9

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  module Shortcuts
    module 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 = {}|
        self.V(from)
            .outE(label).where(__.inV.hasId(to))
            .fold
            .coalesce(
              __.unfold,
              __.addE(label).from(__.V(from)).to(__.V(to)).props(**create_properties)
            ).props(**update_properties)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
grumlin-0.23.0 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.5 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.4 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.3 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.2 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.1 lib/grumlin/shortcuts/upserts.rb
grumlin-0.22.0 lib/grumlin/shortcuts/upserts.rb
grumlin-0.21.1 lib/grumlin/shortcuts/upserts.rb
grumlin-0.21.0 lib/grumlin/shortcuts/upserts.rb