Class: OrientDbClient::DatabaseSession
- Defined in:
- lib/orient_db_client/database_session.rb
Instance Attribute Summary collapse
-
#clusters ⇒ Object
readonly
Returns the value of attribute clusters.
Attributes inherited from Session
Instance Method Summary collapse
- #close ⇒ Object
- #cluster_exists?(cluster_id) ⇒ Boolean
- #count(cluster_name) ⇒ Object
- #create_physical_cluster(name, options = {}) ⇒ Object
- #create_record(cluster_id, record) ⇒ Object
- #delete_cluster(cluster_id) ⇒ Object
- #delete_record(rid_or_cluster_id, cluster_position_or_version, version = nil) ⇒ Object
- #get_cluster(id) ⇒ Object
- #get_cluster_datarange(cluster_id) ⇒ Object
-
#initialize(id, connection, clusters = []) ⇒ DatabaseSession
constructor
A new instance of DatabaseSession.
- #load_record(rid_or_cluster_id, cluster_position = nil) ⇒ Object
- #query(text, options = {}) ⇒ Object
- #reload ⇒ Object
- #update_record(record, rid_or_cluster_id, cluster_position_or_version, version = :none) ⇒ Object
Constructor Details
#initialize(id, connection, clusters = []) ⇒ DatabaseSession
Returns a new instance of DatabaseSession.
7 8 9 10 11 |
# File 'lib/orient_db_client/database_session.rb', line 7 def initialize(id, connection, clusters = []) super id, connection store_clusters(clusters) end |
Instance Attribute Details
#clusters ⇒ Object (readonly)
Returns the value of attribute clusters.
5 6 7 |
# File 'lib/orient_db_client/database_session.rb', line 5 def clusters @clusters end |
Instance Method Details
#close ⇒ Object
13 14 15 |
# File 'lib/orient_db_client/database_session.rb', line 13 def close @connection.close_database(@id) end |
#cluster_exists?(cluster_id) ⇒ Boolean
17 18 19 |
# File 'lib/orient_db_client/database_session.rb', line 17 def cluster_exists?(cluster_id) @connection.cluster_exists?(@id, cluster_id) end |
#count(cluster_name) ⇒ Object
21 22 23 |
# File 'lib/orient_db_client/database_session.rb', line 21 def count(cluster_name) @connection.count(@id, cluster_name) end |
#create_physical_cluster(name, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/orient_db_client/database_session.rb', line 25 def create_physical_cluster(name, = {}) .merge!({ :name => name }) @connection.create_cluster(@id, :physical, ) end |
#create_record(cluster_id, record) ⇒ Object
35 36 37 |
# File 'lib/orient_db_client/database_session.rb', line 35 def create_record(cluster_id, record) @connection.create_record(@id, cluster_id, record) end |
#delete_cluster(cluster_id) ⇒ Object
39 40 41 |
# File 'lib/orient_db_client/database_session.rb', line 39 def delete_cluster(cluster_id) @connection.delete_cluster(@id, cluster_id) end |
#delete_record(rid_or_cluster_id, cluster_position_or_version, version = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/orient_db_client/database_session.rb', line 43 def delete_record(rid_or_cluster_id, cluster_position_or_version, version = nil) if rid_or_cluster_id.is_a?(OrientDbClient::Rid) rid = rid_or_cluster_id version = cluster_position_or_version.to_i else rid = OrientDbClient::Rid.new(rid_or_cluster_id.to_i, cluster_position_or_version.to_i) version = version end @connection.delete_record(@id, rid, version) end |
#get_cluster(id) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/orient_db_client/database_session.rb', line 55 def get_cluster(id) if id.kind_of?(Fixnum) @clusters[id] else @clusters_by_name[id.downcase] end end |
#get_cluster_datarange(cluster_id) ⇒ Object
63 64 65 |
# File 'lib/orient_db_client/database_session.rb', line 63 def get_cluster_datarange(cluster_id) @connection.get_cluster_datarange(@id, cluster_id) end |
#load_record(rid_or_cluster_id, cluster_position = nil) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/orient_db_client/database_session.rb', line 67 def load_record(rid_or_cluster_id, cluster_position = nil) if rid_or_cluster_id.is_a?(Fixnum) rid_or_cluster_id = OrientDbClient::Rid.new(rid_or_cluster_id, cluster_position) end @connection.load_record(@id, rid_or_cluster_id)[:message_content] end |
#query(text, options = {}) ⇒ Object
75 76 77 |
# File 'lib/orient_db_client/database_session.rb', line 75 def query(text, = {}) @connection.query(@id, text, ) end |
#reload ⇒ Object
79 80 81 |
# File 'lib/orient_db_client/database_session.rb', line 79 def reload @connection.reload(@id) end |
#update_record(record, rid_or_cluster_id, cluster_position_or_version, version = :none) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/orient_db_client/database_session.rb', line 83 def update_record(record, rid_or_cluster_id, cluster_position_or_version, version = :none) if rid_or_cluster_id.is_a?(Fixnum) rid = OrientDbClient::Rid.new(rid_or_cluster_id, cluster_position_or_version) version = version else rid = rid_or_cluster_id version = cluster_position_or_version end @connection.update_record(@id, rid, record, version) end |