def ids(data)

      # Just return if nothing to do
      return data if data and data.empty?

      # Support passing id as string
      data = {'_id' => data} if !data or data.is_a?(String)

      # Turn all keys to string
      data = data.stringify_keys

      # Convert id to _id for mongo
      data['_id'] = data.delete('id') if data['id']

      # Convert ids to BSON ObjectId
      data.each do |k, v|
        if v.is_a?(String) and v =~ /^[0-9a-fA-F]{24}$/
          data[k] = oid(v)
        end
      end

      # Return data
      data
    end
def ids(data)

      # Just return if nothing to do
      return data if data and data.empty?

      # Support passing id as string
      data = {'_id' => data} if !data or data.is_a?(String)

      # Turn all keys to string
      data = data.stringify_keys

      # Convert id to _id for mongo
      data['_id'] = data.delete('id') if data['id']

      # Convert ids to BSON ObjectId
      data.each do |k, v|
        if v.is_a?(String) and v =~ /^[0-9a-fA-F]{24}$/
          data[k] = oid(v)
        end
      end

      # Return data
      data
    end
Make sure data is optimal