From 7380892d3e94c2eece47eda14a88c45f48e363be Mon Sep 17 00:00:00 2001 From: 637f075a0567bd2c57c77830 <637f075a0567bd2c57c77830@devide> Date: Mon, 26 Jun 2023 02:43:00 +0000 Subject: [PATCH] Mon Jun 26 02:43:00 UTC 2023 inscode --- index.js | 66 ++++++++++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/index.js b/index.js index 78fe026..6c1c85d 100644 --- a/index.js +++ b/index.js @@ -1,42 +1,28 @@ - -const { MongoClient, ServerApiVersion } = require('mongodb'); -const uri = "mongodb+srv://wrvr:qqqq258369@cluster0.kmggvco.mongodb.net/?retryWrites=true&w=majority"; - -// Create a MongoClient with a MongoClientOptions object to set the Stable API version -const client = new MongoClient(uri, { - serverApi: { - version: ServerApiVersion.v1, - strict: true, - deprecationErrors: true, +var axios = require('axios'); +var data = JSON.stringify({ + "collection": "mycollection", + "database": "mydatabase", + "dataSource": "Cluster0", + "projection": { + "_id": 1 } }); - -async function run() { - try { - // Connect the client to the server (optional starting in v4.7) - await client.connect(); - // Send a ping to confirm a successful connection - await client.db("admin").command({ ping: 1 }); - console.log("Pinged your deployment. You successfully connected to MongoDB!"); - - // Get a reference to the database - const db = client.db('mydatabase'); - - // Get a reference to the collection - const collection = db.collection('mycollection'); - - // Insert a document - const resultInsert = await collection.insertOne({ name: 'Alice3', age: 30 }); - console.log(`Inserted ${resultInsert.insertedCount} documents into the collection`); - - // Find documents - const resultFind = await collection.find({ age: { $gt: 25 } }).toArray(); - console.log(`Found ${resultFind.length} documents that match the query`); - console.log(resultFind); - - } finally { - // Ensures that the client will close when you finish/error - await client.close(); - } -} -run().catch(console.dir); + +var config = { + method: 'post', + url: 'https://ap-southeast-1.aws.data.mongodb-api.com/app/data-jmriv/endpoint/data/v1/action/findOne', + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Request-Headers': '*', + 'api-key': 'RddbxMZlXN9uX3qKx39q58CoRWjkiyb8qihoOo5bLAnVVpmi5hmKeMHKQVvNfb8O', + }, + data: data +}; + +axios(config) + .then(function (response) { + console.log(JSON.stringify(response.data)); + }) + .catch(function (error) { + console.log(error); + }); -- GitLab