beginning of the MongoDB database logic code