Overview

This manual is divided into several sections, each focusing on a specific aspect of the MongoDB-Kognitos integration.

Introduction

The integration of MongoDB with Kognitos offers a powerful and intuitive way to interact with MongoDB databases. This integration enables users to perform a wide range of operations on MongoDB collections, including querying, creating, updating, and deleting documents, all through the use of Kognitos’ natural language processing capabilities. This section provides an overview of the MongoDB-Kognitos integration and outlines the prerequisites for using MongoDB on Kognitos.

Prerequisites for Using Kognitos with MongoDB

Before you can start using Kognitos to interact with MongoDB, there are several prerequisites that need to be met:

  1. MongoDB Account: You need to have an active MongoDB account. If you do not have one, you can sign up for a MongoDB Atlas account to get started.
  2. MongoDB URI: Ensure that you have the MongoDB URI for your database. This URI is required for Kognitos to connect to your MongoDB instance securely.
  3. Basic Understanding of MongoDB Collections and Documents: While Kognitos simplifies interactions, having a basic understanding of MongoDB collections and documents will help you automate more effectively with Kognitos.

Once these prerequisites are met, you are ready to start leveraging the power of Kognitos to enhance your MongoDB experience, making it more accessible, efficient, and customizable.


Setting Up MongoDB Connection

Connecting to MongoDB

To interact with MongoDB using Kognitos, establishing a secure connection to your MongoDB instance is the first critical step. This section outlines the credentials required for this connection and provides a detailed, step-by-step guide to connect successfully.

Required Credentials

To connect to MongoDB, you will need the following credentials:

  1. MongoDB URI: The connection string for your MongoDB instance. This URI is unique to your database and can be found in your MongoDB Atlas dashboard or your MongoDB configuration.
  2. Database Name: The name of the database you want to connect to within your MongoDB instance.

Step-by-Step Connection Process

  1. Gather Credentials: Ensure you have all the required credentials: MongoDB URI and database name.

  2. Connect MongoDB to Kognitos: To initiate a connection to MongoDB, you will use a specific procedure designed for connecting to external services.

    connect to mongodb with
        the mongo uri is "mongodb+srv://<username>:<password>@<host>/<dbname>?retryWrites=true&w=majority"
        the mongo database is "myDatabase"
    

    Replace <username>, <password>, <host>, and <dbname> with your actual MongoDB credentials and database name.

    connect to mongodb with
        the mongo uri is "mongodb+srv://testuser:abc.mongodb.net/?retryWrites=true"
        the mongo database is "test"
    
  3. Verify Connection: After executing the above command, Kognitos will attempt to establish a connection to MongoDB using the provided credentials. If the connection is successful, you can proceed with further operations like fetching, creating, or modifying MongoDB documents. If the connection fails, verify your credentials and ensure that your MongoDB URI and database name are correct.

  4. Connection Established: Once the connection is successfully established, you are ready to perform various operations on MongoDB. You can now fetch data, create new documents, update existing ones, delete documents, and more.


Working with MongoDB Documents

Interacting with MongoDB documents is a core functionality when integrating MongoDB with Kognitos. This section covers how to fetch data, create and modify MongoDB documents, and delete them when necessary.

Fetching Data using Custom Queries

To fetch data from MongoDB using custom queries, see the examples below.

connect to mongodb with
    the mongo uri is "mongodb+srv://testuser:abc.mongodb.net/?retryWrites=true"
    the mongo database is "test"
get mongodb's employees whose name is "John Doe"
connect to mongodb with
    the mongo uri is "mongodb+srv://testuser:abc.mongodb.net/?retryWrites=true"
    the mongo database is "test"
get mongodb's products whose price is greater than 100
connect to mongodb with
    the mongo uri is "mongodb+srv://testuser:abc.mongodb.net/?retryWrites=true"
    the mongo database is "test"
get mongodb's orders which are the latest two

Creating and Modifying MongoDB Documents

Adding New Documents

To add a new document to MongoDB, you need to specify the type of document you're creating and provide the necessary field values.

Example:

connect to mongodb with
    the mongo uri is "mongodb+srv://testuser:abc.mongodb.net/?retryWrites=true"
    the mongo database is "test"
create a person as follows
    the person's name is "John"
    the person's age is 30
add the person to mongodb

This command creates a new document in the "person" collection with the specified name and age.

Updating Existing Documents

To update an existing MongoDB document, you must identify the document by its ID and specify the fields you want to update.

Example:

connect to mongodb with
    the connection string is "mongodb://localhost:27017"
    the database is "testDB"
get the mongodb_object where
    the _id is "507f1f77bcf86cd799439011"
set the mongodb_object's name to "John Doe"

This command updates the name of the specified document to "John Doe".

connect to mongodb with
    the connection string is "mongodb://localhost:27017"
    the database is "testDB"
get the mongodb_object where
    the _id is "507f1f77bcf86cd799439011"
change the mongodb_object's status to "active"

This command updates the status of the specified document to "active".

Deleting MongoDB Documents

Single Deletion

To delete a specific MongoDB document, you need to specify the document and its ID.

Example:

connect to mongodb with
    the connection string is "<connection-string>"
delete the mongodb_object with
    the _id is "507f1f77bcf86cd799439011"

This command deletes the document with the specified ID.

By following these guidelines, you can effectively manage MongoDB documents in Kognitos, from fetching and creating records to updating and deleting them as needed.


Glossary of Terms

  • MongoDB URI: The connection string used to connect to a MongoDB instance. It includes the username, password, host, and database name.
  • MongoDB Collection: A grouping of MongoDB documents. Collections are analogous to tables in relational databases.
  • MongoDB Document: A single data entry within a MongoDB collection. Documents are analogous to rows in relational databases and are stored in BSON format.
  • Kognitos: A platform that uses natural language processing to interact with various services, including MongoDB, making it easier to perform database operations through intuitive commands.