This file contains 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
module SingletonWithClassDelegator | |
extend ActiveSupport::Concern | |
included do | |
include Singleton | |
original_delegate_method = method(:delegate).unbind if self.respond_to?(:delegate) | |
extend SingleForwardable | |
if original_delegate_method.present? | |
# restore the delegate of ActiveSupport that has been overshadowed by SingleForwardable | |
define_singleton_method :delegate, original_delegate_method |
This file contains 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
# ActiveRecord's find_each and find_in_batches ported to Sequel. | |
# Sequel's paged_each is not practical when converting large data due to its use of transaction and offset. | |
# | |
# Usage: | |
# | |
# SequelEachInBatches.find_each(dataset, keys) { |record| ... } | |
# | |
# It can also monkey patch Sequel::Dataset: | |
# | |
# Sequel::Dataset.send(:include, SequelEachInBatches) |
This file contains 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
"use strict"; | |
const Sequelize = require('sequelize'); | |
const Promise = Sequelize.Promise; | |
const DEFAULT_BATCH_SIZE = 3000; | |
/** | |
* Port of ActiveRecord::Base.find_each of Rails. |
OlderNewer