lib/trifle/stats/driver/mongo.rb in trifle-stats-1.2.0 vs lib/trifle/stats/driver/mongo.rb in trifle-stats-1.3.0
- old
+ new
@@ -14,9 +14,14 @@
@client = client
@collection_name = collection_name
@separator = '::'
end
+ def self.setup!(client, collection_name: 'trifle_stats')
+ client[collection_name].create
+ client[collection_name].indexes.create_one({ key: 1 }, unique: true)
+ end
+
def inc(keys:, **values)
data = self.class.pack(hash: { data: values })
collection.bulk_write(
keys.map do |key|