Sha256: c5b695c65670374ef18ad328307a589881f61796474b08d78d00768d6ecc2bac

Contents?: true

Size: 824 Bytes

Versions: 8

Compression:

Stored size: 824 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( # TODO: extract upsert pattern to a shortcut
              __.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

8 entries across 8 versions & 1 rubygems

Version Path
grumlin-0.19.7 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.6 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.5 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.4 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.3 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.2 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.1 lib/grumlin/shortcuts/upserts.rb
grumlin-0.19.0 lib/grumlin/shortcuts/upserts.rb