lib/waxx/mongodb.rb in waxx-0.1.2 vs lib/waxx/mongodb.rb in waxx-0.1.3
- old
+ new
@@ -1,9 +1,10 @@
# Waxx Copyright (c) 2016 ePark labs Inc. & Daniel J. Fitzpatrick <dan@eparklabs.com> All rights reserved.
# Released under the Apache Version 2 License. See LICENSE.txt.
module Waxx::Mongodb
+ extend self
attr :db
attr :table
attr :columns
attr :pkey
@@ -18,10 +19,14 @@
@joins = {}
@orders = {}
has(cols) if cols
end
+ def connect(str)
+ Mongo::Client.new(str).database
+ end
+
def has(opts=nil)
init if @table.nil?
return @columns if opts.nil?
@columns = opts
@columns.each{|n,v|
@@ -41,9 +46,13 @@
r, tc = v[:has].split(":")
t, c = tc.split(".")
@joins[r] = {join: "LEFT", table: t, col: c}
end
}
+ end
+
+ def connect(conf)
+ ::Mongo::Client.new(conf).database
end
def [](n)
@columns[n.to_sym]
end