Class: Arcade::Document

Inherits:
Base
  • Object
show all
Defined in:
lib/model/document.rb

Direct Known Subclasses

Basicdocument, RevisionRecord

Class Method Summary collapse

Methods inherited from Base

#==, #accepted_methods, all, begin_transaction, commit, count, create_type, database_name, #delete, descendants, drop_type, find, first, #html_attributes, #in_and_out_attributes, insert, #insert_document, #inspect, #invariant_attributes, last, #method_missing, not_permitted, properties, query, #query, #refresh, #rid?, rollback, timestamps, #to_html, #to_human, #to_json, #to_or, update, #update, update!, #update_embedded, #update_list, #update_map, upsert, where

Methods included from Support::Sql

#compose_where, #generate_sql_list

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arcade::Base

Class Method Details

.create(**attributes) ⇒ Object

def accepted_methods

end



9
10
11
# File 'lib/model/document.rb', line 9

def self.create **attributes
  Api.create_document  db.database, database_name, session_id: db.session,  **attributes
end

.delete(where: {}, **args) ⇒ Object

Document.delete fires a “delete” command to the database.

To remove all records  use  


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/model/document.rb', line 19

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