How to connect to MongoDB and remove a document from a collection using Katalon Keyword

I have seen people struggling with connecting to MongoDb using Katalon. I have figured this out and even learned how to remove a document from a collection. Here is the code needed when creating a custom keyword to handle connecting and removing a document.

Code below:
package qatest //this is the name of my package but name yours whatever you like

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import as Windows
import internal.GlobalVariable
import com.mongodb.BasicDBObject;
import com.mongodb.BulkWriteOperation;
import com.mongodb.BulkWriteResult;
import com.mongodb.Cursor;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.ParallelScanOptions;
import com.mongodb.ServerAddress;
import com.mongodb.MongoCredential
import com.mongodb.MongoClientOptions

// this is the name of my keyword but name yours whatever you like
public class MongoDB {


def ConnectAndRemoveApplication(String appId) //i pass an appId from the test script
	String pwdString = 'you will put the pwd to your mongodb here'
	char[] pwd = new char[pwdString.length()]
	pwdString.getChars(0, pwdString.length(), pwd, 0)
	MongoClientOptions.Builder builder = MongoClientOptions.builder()
	builder.sslEnabled(true).build() //you will need this if ssl is necessary to connect to your mongodb
	MongoClientOptions sslOptions =
	MongoCredential credential = MongoCredential.createCredential('username of your mongodb goes here', 'name of your db goes here', pwd)
	MongoClient mongoClient = new MongoClient(new ServerAddress('server address goes here', port number goes here), Arrays.asList(credential), sslOptions);
	DB db = mongoClient.getDB('name of your db goes here')
	DBObject query = new BasicDBObject("_id", appId) //here i am passing the key and appId i want to delete