我有一个类似这样的 mongoDB 方案
new Schema({
productDetail: [ {
productYear: String,
productNumber: String,
productType: [ { type: Schema.ObjectId, ref: 'type' } ]
} ],
created_at: string
)}
在 Rails 和 mongoid 中尝试相同的方法我无法将子元素和数据类型添加到 Hash 对象
class Product
include Mongoid::Document
has_many :types
field :productDetail, type: Hash
field :created_at, type: string
end
这甚至可能吗?