MySQL is an open-source relational database management system.
MySQL is a powerful database management system used by some of the largest
organizations in the world, including Facebook, Google, and Amazon. MySQL is an
open-source relational database management system (RDBMS), as well as a popular
choice for web applications used by millions of websites.
Some applications that can be built using the MySQL API include:
import mysql from 'mysql2/promise';
export default defineComponent({
props: {
mysql: {
type: "app",
app: "mysql",
}
},
async run({steps, $}) {
const {
host,
port,
username: user,
password,
database,
ca,
key,
cert,
reject_unauthorized: rejectUnauthorized,
} = this.mysql.$auth;
const isRejectUnauthorizedUndefined = rejectUnauthorized === undefined;
const isSslSet = !!(ca && key && cert);
const connectionConfig = {
host,
port,
user,
password,
database,
...(isSslSet && {
ssl: {
rejectUnauthorized: true,
ca,
cert,
key,
},
}),
...(!isSslSet && !isRejectUnauthorizedUndefined && {
ssl: {
rejectUnauthorized,
},
}),
};
const connection = await mysql.createConnection(connectionConfig);
const [rows] = await connection.execute('SELECT NOW()');
return rows;
},
});
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()
},
})