【发布时间】:2019-05-16 14:52:55
【问题描述】:
我有以这种方式在 MongoMapper 中保存数据的模型
class WellIndex::Core
include MongoMapper::Document
key :well_name
key :surface_loc, Hash
ensure_index [[:surface_loc, '2dsphere']]
end
数据以这种方式存储
well.surface_loc # {:type => "Point", :coordinates => [-90, 10]}
我在 Mongoid 中看到您将地理数据存储到数组中。这个类将转换为
class WellIndex::Core
include Mongoid::Document
field :well_name, type: String
field :surface_loc, Array
index({:surface_loc => '2dsphere'})
end
这样我必须将所有数据迁移到一个新字段,因为数据是 Hash,有没有办法我仍然可以在 Mongoid 中使用相同的 Hash 数据强>?
【问题讨论】: