Sha256: 9cce0c5ca5991a449e96ffa4bbc7d5ed8f19e5c5dda5e1c8d6a2560e13f73ff1
Contents?: true
Size: 993 Bytes
Versions: 1
Compression:
Stored size: 993 Bytes
Contents
require 'mongo' #class for communication with mongo database for iot API class MongoIot attr_accessor :mongoip, :mongoport, :client, :database def initialize(mongoip, mongoport, iotip, database) @database = database @mongoip = mongoip @mongoport = mongoport @iotip = iotip client_host = [mongoip + ":" + mongoport] @client = Mongo::Client.new(client_host, :database => database) end def ttt p "111111" begin puts(client.cluster.inspect) puts puts('Collection Names: ') puts(client.database.collection_names) puts('Connected!') collection = client[:audit] doc = { name: 'Steve', hobbies: [ 'hiking', 'tennis', 'fly fishing' ], siblings: { brothers: 0, sisters: 1 } } result = collection.insert_one(doc) p result client.close rescue StandardError => err puts('Error: ') puts(err) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
imperituroard-0.1.8 | lib/imperituroard/projects/iot/mongoconnector.rb |