我有一個由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