rails mongo查询基于BSON :: ObjectId外键

时间:2018-02-27 17:49:04

标签: ruby-on-rails mongodb

Mongodbrails

Parent对象has_many :children

Childparent_id个班级BSON::ObjectId

Child.first.parent_id
=> BSON::ObjectId('59031cd92936094d04000d31') 

我找不到Parent

_id
Parent.where(_id: '59031cd92936094d04000d31').first
 => nil 

Parent对象看起来像这样

 => #<Parent _id: 5a959865c8aedf03c1000007, _type: nil, created_at: nil, updated_at: nil, id: nil, name: nil, description: nil, type: nil, starts_at: nil, children_hash: nil> 

0 个答案:

没有答案
相关问题