Apicat Docs
  1. Database operations
Apicat Docs
  • What is Apicat?
  • Send requests
    • Create requests
      • Request basics
      • Parameters and body
      • Request headers
      • Request settings
      • Dynamic values
      • HTTP/2
      • SOAP/WebService
    • Authentication and authorization
      • Overview
      • CA and client certificates
      • Authorization types supported by Apidog
      • Digest Auth
      • OAuth 1.0
      • OAuth 2.0
      • Hawk Authentication
      • Kerberos
      • NTLM
      • Akamai EdgeGrid
    • Response and cookies
      • Overview
      • API response in Apidog
      • Create and send cookies
      • Debug requests
    • Dynamic values Modules
      • Airline
      • Animal
      • Color
      • Commerce
      • Company
      • Database
      • Datatype
      • Date
      • Finance
      • Food
      • Git
      • Hacker
      • Helpers
      • Image
      • Internet
      • Location
      • Lorem
      • Music
      • Number
      • Person
      • Phone
      • Science
      • String
      • System
      • Vehicle
      • Word
  • Environments & variables
    • Overview
    • Using variables
    • Environments & services
  • Pre/Post processors
    • Overview
    • Assertion
    • Extract variable
    • Wait
    • Database operations
      • Overview
      • MySQL
      • MongoDB
      • Redis
      • Oracle Client
    • Using scripts
      • Overview
      • Pre processor scripts
      • Post processor scripts
      • Public scripts
      • Postman scripts reference
      • Calling other programming languages
      • Using JS libraries
      • Visualizing responses
      • Script examples
        • Assertion scripts
        • Using variables in scripts
        • Using scripts to modify request messages
        • Other examples
  • Best practices
    • How to handle API signatures
    • How to access OAuth 2.0 protected APIs
    • Apidog collaboration workflow
    • Managing authentication state in Apidog
  • Account & preferences
    • Account settings
    • Generate OpenAPI access token
    • Language settings
    • Hot keys
    • Network proxy configuration
    • Data backup
    • Updating Apidog
    • Deleting account
    • Experimental Features
  • References
    • API-Design First Approach
    • Apidog OpenAPI/Swagger Specificaiton Extensions
    • JSONPath
    • XPath
    • Regular Expressions
    • JSON Schema
    • CSV File Format
    • Install Java Environment
    • Runner deployment environment
    • Apidog flavored Markdown
  1. Database operations

MongoDB

Connecting to the MongoDB database is a paid feature. Check Pricing Details to learn more.
MongoDB is a document-oriented database management system belonging to non-relational databases (NoSQL). It aims to provide scalable high-performance data storage solutions for web applications. Unlike relational databases (SQL), MongoDB does not use SQL statements to operate on the database, but uses database commands (Database Commands) or simpler and more user-friendly methods of adding, deleting, querying and modifying data. Further reading: MongoDB Documentation.

Connect to the database#

1.
When adding database operations, click Database Connetions and select Manage Database Connection.
image.png
2.
Click the "New" button in the upper right corner.
3.
Select MongoDB database type, then fill in the corresponding connection information.
TIP
Apidog attaches importance to your data security. The database address, port, username, password, database name are only stored locally on the client and will not be synced to the cloud. Even within the same team, connection information for databases will not be synced between members. Each team member needs to manually set up the database connection.

Operate the database#

MongoDB stores data in BSON document format. For convenience of most user's usage habits, when modifying MongoDB databases in Apidog, submit JSON format files. The system will automatically map each field to the corresponding BSON data type based on the actual content of the JSON.
Among them, the _id field is relatively special. According to MongoDB specifications, each document must have an _id field as the primary key, and the default data type of this field is ObjectId rather than String.
If you need to declare an _id field of type ObjectId, you can use the conventional string format. If the string content conforms to the ObjectId format, Apidog will automatically map it to the ObjectId type in BSON.
Assume there is such a BSON document in MongoDB now:
{
    _id: ObjectId('6569a36afcf5ee79c08d2f94'),
    name: "Apidog"
}
So when using Apidog to query the document via _id, the JSON value that needs to be entered in the "Query Conditions" is:
{
    "_id": "6569a36afcf5ee79c08d2f94"  
}

Common operations#

For common CRUD operations, support via visual API operations. No need to write any JavaScript code, just specify the action in the "Operation Type", then specify the "Collection Name", and then write the corresponding content in JSON in "Query Conditions".
For example, for the query operation mentioned above, you can view the queried document in the console after entering the command and enabling "Console Log".

Advanced commands#

If you need more advanced operations, you can also directly run database commands. In "Operation Type", select "Run Database Command" and then enter the database command in JSON format. Note that the database command does not refer to method calls like db.collection.findOne(), but JSON data in a specific format.
For example, to query the number of documents in the users collection, you can use the count database command:
{
    "count": "users"
}
After entering the command, you can view the result in the console.
Modified at 2025-06-25 07:57:16
Previous
MySQL
Next
Redis
Built with