Sha256: 2674974249ec2c929059c83ac51d54f716d2df2e3cf3de76930b72d0e2c74140
Contents?: true
Size: 642 Bytes
Versions: 9
Compression:
Stored size: 642 Bytes
Contents
require 'bundler/setup' require 'groovy' Groovy.open('./db/products') class Product include Groovy::Model schema do |t| t.string :name t.integer :price t.timestamps end scope :by_price, -> { puts self.inspect; sort_by(price: :asc) } scope :named, -> (name) { puts self.inspect; where(name: name) if name } end def populate 5_000.times do |i| puts "Creating product #{i}" if i % 1000 == 0 Product.create!(name: "A product with index #{i}", price: 10000 + i % 10) end end populate if Product.count == 0 # 50_000 products: 50M # 100_000 products: 50M # 500_000 products: 62M
Version data entries
9 entries across 9 versions & 1 rubygems