Sha256: 1c7de92df71b7c0dd9529413c5742445026136f9403d6064fefddd24c0eb6de1

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

module Arcade
  class Document  <  Base
   # schema schema.strict    #  -- throws an error if  specified keys are missing

    ## has to be overloaded
   # def accepted_methods
   #
   # end
   def self.create **attributes
     Api.create_document  db.database, database_name, session_id: db.session,  **attributes
   end

=begin
    Document.delete fires a "delete vertex" command to the database.
    To remove all records  use  »all: true« as argument

    The "where" parameter is optional
=end
    def self.delete where: {} , **args
      if args[:all] == true
        where = {}
      else
        where.merge!(args) if where.is_a?(Hash)
        return 0 if where.empty?
      end
      # query returns [{count => n }]
      #  puts "delete from  #{database_name} #{compose_where(where)}"
      db.transmit { "delete  from `#{database_name}` #{compose_where(where)}"   } &.first[:count] rescue 0
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arcadedb-0.5.0 lib/model/document.rb