Skip to content

Instantly share code, notes, and snippets.

require 'mongoid'
Mongoid.configure do |config|
config.clients.default = {
hosts: ['localhost:27017'],
database: 'junk_db',
options: {
truncate_logs: false
}
}
@boazadato
boazadato / save_test.rb
Created April 25, 2022 06:13
playing with mongoid save vs changed vs array relations
require 'mongoid'
Mongoid.configure do |config|
config.clients.default = {
hosts: ['localhost:27017'],
database: 'junk_db',
}
config.raise_not_found_error = false
end
@boazadato
boazadato / idhack-vs-IXSCAN.rb
Created February 17, 2022 10:11
Reproducing Mongoid 7.3.3 simple find possible performance issue
require 'mongoid'
Mongoid.configure do |config|
config.clients.default = {
hosts: ['localhost:27017'],
database: 'junk_db',
}
config.raise_not_found_error = false
end
@boazadato
boazadato / mongoid-embeded-doc-update-skipped.rb
Created January 27, 2022 20:44
Reproduce a scenario in which mongoid does not update if a different _id is provided
require 'mongoid'
Mongoid.configure do |config|
config.clients.default = {
hosts: ['localhost:27017'],
database: 'junk_db',
}
end
class Contained
@boazadato
boazadato / city2state.json
Created November 12, 2017 22:38
map city to state US + CA
{
"Anchorage": "AK",
"Anderson": "TX",
"Angoon": "AK",
"Atqasuk": "AK",
"Barrow": "AK",
"Bethel": "CT",
"Clear": "AK",
"Cordova": "IL",
"Craig": "MO",