Method: NoSE::Backend::MongoBackend.rows_from_mongo
- Defined in:
- lib/nose/backend/mongo.rb
.rows_from_mongo(rows, index, fields = nil) ⇒ Array<Hash>
Convert documens returned from MongoDB into the format we understand
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/nose/backend/mongo.rb', line 113 def self.rows_from_mongo(rows, index, fields = nil) fields = index.all_fields if fields.nil? rows.map! do |row| Hash[fields.map do |field| field_path = MongoBackend.field_path(index, field) [field.id, field_path.reduce(row) { |h, p| h[p] }] end] end end |