MongoDB
Overview
The MongoDB class is designed to interact with a MongoDB database for storing and retrieving passage contents. It provides methods for creating, loading, saving, fetching, and searching passages in a MongoDB collection.
Usage
1. Make MongoDB Instance with Your MongoDB
To start using the MongoDB class, you first need to create an instance of the class. You can do this by providing the URL of your MongoDB server, the name of your database, and the name of your collection.
2. Use create_or_load
The create_or_load
method is used to either create a new collection if it does not exist, or load an existing collection.
3. Save Passage
You can save passages to your MongoDB collection using the save
method. This method accepts a list of Passage objects.
4. Fetch Data
The fetch
method allows you to retrieve passages from your MongoDB collection by their IDs. This method returns a list of Passage objects.
5. Search Data
You can search for passages in your MongoDB collection using the search
method. This method accepts filters such as passage ID, content, filepath, and metadatas, then returns a list of Passage objects that match the filters.
Please replace the placeholders with your actual data. Also, make sure that your MongoDB server is running and accessible at the provided URL.
Last updated