Sha256: b0fbaf1b0fa201a5e80e9d3e66d44254cfdf94ecc9dad7f65e5a7cb27d1861a9

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 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(**create_properties.merge(T.id => id))
            ).props(**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

3 entries across 3 versions & 1 rubygems

Version Path
grumlin-0.20.2 lib/grumlin/shortcuts/upserts.rb
grumlin-0.20.1 lib/grumlin/shortcuts/upserts.rb
grumlin-0.20.0 lib/grumlin/shortcuts/upserts.rb