我有一个由BSON::ObjectId
类型组成的数组,我希望它作为字符串与某些ID进行比较。比较字符串ID到BSON :: ObjectId
if my_array_of_BSON_ObjectIds.include?(@my_id_as_a_string)
# delete the item from the array
else
# add the item to the array as a BSON::ObjectId
end
这不是工作的类型是不同的,我可以把我的字符串转换成BSON::ObjectId
?如果是这样,怎么样?
这对我的作品的oid ='BSON :: ObjectId.from_string( '506144650ed4c08d84000001')',但不与Mongope 4上的'轻便摩托车'。 – Dex