Assuming you want a few paragraph about the MongoDB API:
MongoDB offers a powerful API that allows developers to interact with their databases in a variety of ways. The API provides methods for performing standard CRUD (create, read, update, delete) operations, as well as more specialized methods like bulk write operations and aggregate queries. MongoDB also offers a rich set of indexing options that allow developers to optimize their queries for maximum performance. With the MongoDB API, developers can build a wide variety of applications, from simple data-driven apps to complex event-driven systems.
import mongodb from 'mongodb'
export default defineComponent({
props: {
mongodb: {
type: "app",
app: "mongodb",
},
collection: {
type: "string"
},
filter: {
type: "object"
}
},
async run({steps, $}) {
const MongoClient = mongodb.MongoClient
const {
database,
hostname,
username,
password,
} = this.mongodb.$auth
const url = `mongodb+srv://${username}:${password}@${hostname}/test?retryWrites=true&w=majority`
const client = await MongoClient.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true
})
const db = client.db(database)
const results = await db.collection(this.collection).find(this.filter).toArray();
$.export('results', results);
await client.close()
},
})
Create a new document in a collection of your choice. See the docs here
Search for specific documents or return all documents. See the docs here
MongoDB uses API keys for authentication. When you connect your MongoDB account, Pipedream securely stores the keys so you can easily authenticate to MongoDB APIs in both code and no-code steps.
Before you connect to your Mongo database from Pipedream, please make sure your database is accessible from the public internet. You may need to add a firewall rule allowing connections from 0.0.0.0/0
.
Then, enter the details of your Mongo host / database below.