Last active
March 5, 2019 20:25
-
-
Save jmeirow/5928480 to your computer and use it in GitHub Desktop.
running example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require_relative './connection.rb' | |
require_relative './person.rb' | |
require_relative './command_create_person.rb' | |
require_relative './documents_repository.rb' | |
$DB ||= Connection.db_cqrs | |
x = nil | |
z = nil | |
time = Benchmark.realtime do | |
x = DocumentsRepository.get_person_by_ssn '333558888' #NOT my real ssn :) | |
z = x.mailing_address | |
end | |
pp x.to_h | |
pp z.to_h | |
puts "Time elapsed #{time*1000} milliseconds" | |
# {"first_name"=>"Joseph", | |
# "last_name"=>"Meirow", | |
# "government_id"=>{"type"=>"SSN", "value"=>"333558888"}, | |
# "date_of_birth"=>"1964-09-11 00:00:00 -0400", | |
# "mailing_address"=> | |
# {"aggregate_type"=>"mailing_address", | |
# "aggregate_id"=>"{720195BE-DB5C-4399-8C69-25E0A1FE81C8}", <= Note, this is just a pointer to the real record. | |
# "class_name"=>"AggregatePointer"}, | |
# "aggregate_lookup_value"=>"333558888", | |
# "aggregate_info"=> | |
# {"aggregate_type"=>"person", | |
# "aggregate_id"=>"{41BD9BEC-BADA-47FB-B484-04FFE918EA1B}", | |
# "version"=>"1", | |
# "most_recent_transaction"=>"{851058E9-37A1-4335-80D4-1C77BAAEC191}"}} | |
# {"address1"=>"123 Elm Street ", | |
# "address2"=>" ", | |
# "city"=>"Detroit ", | |
# "state_province"=>"MI", | |
# "zip_postal"=>"48201 ", | |
# "country"=>"USA", | |
# "aggregate_lookup_value"=> | |
# "dbc70e06df9e05b2f2e6c998db78418e780dc287a0040aa41b7096b430baccf5", | |
# "aggregate_info"=> | |
# {"aggregate_type"=>"mailing_address", | |
# "aggregate_id"=>"{720195BE-DB5C-4399-8C69-25E0A1FE81C8}", | |
# "version"=>"1", | |
# "most_recent_transaction"=>"{D23E884F-4CA4-4FD2-9BCF-A6A79483F107}"}} | |
# Time elapsed 15.6 milliseconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment