Class: Moped::Protocol::Insert
- Includes:
- Message
- Defined in:
- lib/moped/protocol/insert.rb
Overview
The Protocol class for inserting documents into a collection.
Instance Attribute Summary collapse
-
#collection ⇒ String, Symbol
readonly
The collection this insert targets.
-
#database ⇒ String, Symbol
readonly
The database this insert targets.
-
#documents ⇒ Array<Hash>
The documents to insert.
-
#flags ⇒ Array
The flags for the query.
-
#full_collection_name ⇒ String
The namespaced collection name.
-
#length ⇒ Number
The length of the message.
-
#op_code ⇒ Number
OP_INSERT operation code (2002).
-
#request_id ⇒ Number
The request id of the message.
Instance Method Summary collapse
-
#initialize(database, collection, documents, options = {}) ⇒ Insert
constructor
Create a new insert command.
- #log_inspect ⇒ Object
Methods included from Message
included, #inspect, #receive_replies, #serialize
Constructor Details
#initialize(database, collection, documents, options = {}) ⇒ Insert
Create a new insert command. The database
and collection
arguments are joined together to set the full_collection_name
.
78 79 80 81 82 83 84 85 86 |
# File 'lib/moped/protocol/insert.rb', line 78 def initialize(database, collection, documents, = {}) @database = database @collection = collection @full_collection_name = "#{database}.#{collection}" @documents = documents @request_id = [:request_id] @flags = [:flags] end |
Instance Attribute Details
#collection ⇒ String, Symbol (readonly)
Returns the collection this insert targets.
61 62 63 |
# File 'lib/moped/protocol/insert.rb', line 61 def collection @collection end |
#database ⇒ String, Symbol (readonly)
Returns the database this insert targets.
58 59 60 |
# File 'lib/moped/protocol/insert.rb', line 58 def database @database end |
#documents ⇒ Array<Hash>
Returns the documents to insert.
47 |
# File 'lib/moped/protocol/insert.rb', line 47 document :documents, type: :array |
#flags ⇒ Array
The flags for the query. Supported flags are: :continue_on_error
.
39 |
# File 'lib/moped/protocol/insert.rb', line 39 flags :flags, continue_on_error: 2 ** 0 |
#full_collection_name ⇒ String
Returns the namespaced collection name.
43 |
# File 'lib/moped/protocol/insert.rb', line 43 cstring :full_collection_name |
#length ⇒ Number
Returns the length of the message.
22 |
# File 'lib/moped/protocol/insert.rb', line 22 int32 :length |
#op_code ⇒ Number
Returns OP_INSERT operation code (2002).
32 |
# File 'lib/moped/protocol/insert.rb', line 32 int32 :op_code |
#request_id ⇒ Number
Returns the request id of the message.
26 |
# File 'lib/moped/protocol/insert.rb', line 26 int32 :request_id |
Instance Method Details
#log_inspect ⇒ Object
88 89 90 91 92 |
# File 'lib/moped/protocol/insert.rb', line 88 def log_inspect type = "INSERT" "%-12s database=%s collection=%s documents=%s flags=%s" % [type, database, collection, documents.inspect, flags.inspect] end |