Method: Mongo::Collection::QueryableEncryption#maybe_drop_emm_collections

Defined in:
lib/mongo/collection/queryable_encryption.rb

#maybe_drop_emm_collections(encrypted_fields, client, session) ⇒ Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Drops auxiliary collections and indices for queryable encryption if necessary.

Parameters:

  • encrypted_fields (Hash | nil)

    Encrypted fields hash that was provided to create collection helper.

  • client (Client)

    Mongo client to be used to drop auxiliary collections.

  • session (Session)

    Session to be used to drop auxiliary collections.

Returns:

  • (Result)

    The result of provided block.

Since:

  • 2.0.0



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/mongo/collection/queryable_encryption.rb', line 62

def maybe_drop_emm_collections(encrypted_fields, client, session)
  encrypted_fields = if encrypted_fields
                       encrypted_fields
                     elsif encrypted_fields_map
                       encrypted_fields_for_drop_from_map
                     else
                       {}
                     end

  return yield if encrypted_fields.empty?

  emm_collections(encrypted_fields).each do |coll|
    context = Operation::Context.new(client: client, session: session)
    operation = Operation::Drop.new(
      selector: { drop: coll },
      db_name: database.name,
      session: session
    )
    do_drop(operation, session, context)
  end

  yield
end