Sha256: 3fab3bb94a8f6c7d7086661a7f15012a44974688b4e8a814981c1e28e161c761
Contents?: true
Size: 1.04 KB
Versions: 32
Compression:
Stored size: 1.04 KB
Contents
module ForestAdminDatasourceToolkit module Components module Query class ProjectionFactory include ForestAdminDatasourceToolkit::Utils def self.all(collection) projection_fields = collection.schema[:fields].reduce([]) do |memo, path| column_name = path[0] schema = path[1] memo += [column_name] if schema.type == 'Column' if schema.type == 'OneToOne' || schema.type == 'ManyToOne' relation = collection.datasource.get_collection(schema.foreign_collection) relation_columns = relation.schema[:fields] .select { |_column_name, relation_column| relation_column.type == 'Column' } .keys .map { |relation_column_name| "#{column_name}:#{relation_column_name}" } memo += relation_columns end memo end Projection.new projection_fields end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems