b0VIM 7.2+ŒòK¾€_výjoshuaiMac.local~joshua/dev/squealer/lib/example_squeal.rbutf-8 U3210#"! Utp\adSß\íìÙ˜q=<õôò´mkEè  k g  ¾ º f S M  Ó Ž ˆ L $  Ñ ¬ s r l F Ò ¿ ‹ W 7   ïØù±°ª‚.í¬«„i_Ú^#ÜÒÑ­”V Ç»¡ˆ‚ih¼r]UñéãßÒ¹¸end end end aend eeeeeeeend end end assign(:disabled) { true } # Source boolean values are converted to integer (0 or 1)... # target(:user) do import.source('users', {:organization_id => organization.id}) do |user|import.source('organization', {:disabled_date => {:$exists => true}}).each do |organization|# Here we use a procedural "join" on related collections to update a target...end #collection("users") end end #user.activities end #activity.tasks end assign(:due_date) #or# assign(:due_date) { task.due_date } assign(:activity_id) #or# assign(:activity_id) { activity._id } assign(:user_id) #or# assign(:user_id) { user._id } target(:task) do activity.tasks.each do |task| end assign(:due_date) #or# assign(:due_date) { activity.due_date } assign(:name) #or# assign(:name) { activity.name } assign(:user_id) #or# assign(:user_id) { user._id } # a variable that is in scope... # of a parent document where the name of the parent collection matches # You can use an empty block to infer the value from the '_id' field # target(:activity) do user.activities.each do |activity| assign(:work_address) { flatten_address(user.work_address) } assign(:home_address) { flatten_address(user.home_address) } # user.home_address = { street: '661 W Lake St', city: 'Chicago', state: 'IL' } # You can denormalize the export... # end end assign(:zip) assign(:state) assign(:city) assign(:street) target(:address) do addresses.each do |address| addresses << atomize_address(user.work_address) addresses << atomize_address(user.home_address) addresses = [] # home_address and work_address are a formatted string like: "661 W Lake St, Suite 3NE, Chicago IL, 60611, USA" # You can normalize the export... # assign(:gender) #or# assign(:gender) { user.gender } # name on the source document... # You can use an empty block to infer the value from a field of the same # assign(:dob) { user.date_of_birth } # You can use a simple access on the source document... # assign(:name) { "#{user.last_name.upcase}, #{user.first_name}" } # You can use an valid arbitrary expression... # # assign() takes a column name and a block to set the value. # target(:user) do # The block parameter |user| above, matches the target() parameter :user below... # # referenced using a variable with the same name as the table name passed to target(). # The primary key value is taken from the '_id' field of the source document, # # Insert or Update on table 'user' where 'id' is the column name of the primary key.import.source('users').each do |user|# Defaults to find all...## import.source("users", "{disabled: 'false'}").each do |user|# Also accepts optional conditions...## import.source("users") { |users| users.find_one() }.each do |user|# You don't want to use a find() on the MongoDB collection...## Here we extract, transform and load all documents in a collection...export('localhost', 'root', '', 'reporting_export')# connect to the target mysql databaseimport('localhost', 27017, 'development')# connect to the source mongodb databaserequire 'squealer'