วิธีการตั้งค่าชนิดข้อมูลสำหรับแฮชในราง (Mongoid)

ฉันมีโครงการ 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

เป็นไปได้ไหม?


person sureshvignesh    schedule 21.02.2017    source แหล่งที่มา
comment
คุณเคยดู stackoverflow.com/a/36477920/1380867 แล้วหรือยัง   -  person MZaragoza    schedule 21.02.2017