370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
# File 'lib/mass_record.rb', line 370
def insert_by_table json_objects, key:{}
begin
tables = json_objects.collect{|x| x[key[:table]]}.to_set.to_a
errors = []
tables.each do |table|
hashes = json_objects.select{|o| o[key[:table]] == table}.collect{|x| x[key[:object]]}
errors += insert hashes, into:table
end
return errors
rescue Exception => e
return ((defined? errors) ? (errors << IndividualError.new(e,operation:"insert")) : [IndividualError.new(e,operation:"insert")])
end
end
|