Sha256: d968ab0c2f91d7f81e5faa3ce680446aa387ef7f567a5e6fc9cfe91c6329f582

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

require_relative '../../logic/schema'
require_relative '../../logic/types'

module Flare
  module DSLSchema
    def transact_schema!(specification, database: nil, debug: nil)
      data = SchemaLogic.specification_to_edn(specification)

      payload = { data: }

      payload[:connection] = { database: { name: database } } unless database.nil?

      response = client.api.transact!(payload, debug:)

      debug ? response : true
    end

    def schema(database: nil, debug: nil)
      database_input = { latest: true }

      database_input[:name] = database unless database.nil?

      payload = {
        inputs: [{ database: database_input }],
        query: SchemaLogic::QUERY
      }

      response = client.api.q(payload, debug:)

      return response if debug

      SchemaLogic.datoms_to_specification(response['data'])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datomic-flare-1.0.1 controllers/dsl/schema.rb
datomic-flare-1.0.0 controllers/dsl/schema.rb