1.0.5 • Published 2 years ago

mongodb-atlas-data-api-sdk v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mongodb-atlas-data-api-sdk

Node SDK for Mongo Atlas Data API

Mongo Atlas recently released a Beta version of a Data API. Using this API you can access your MongoDB commands via API. This SDK attempts to make that as simple as possible.

API Documentation

Mongo Atlas Data API - BETA

Resources

Examples

For examples of how to use the SDK see this repository.

Usage

import MongoAtlasDataApiSDK from 'mongodb-atlas-data-api-sdk'

const mongoAtlasDataApiSdk = new MongoAtlasDataApiSDK({
    apiKey: API_KEY,
    apiUrl: API_URL,
    dbCluster: DB_CLUSTER,
    dbName: DB_NAME,
    quiet: false
})

const { documents } = await mongoAtlasDataApiSdk.find({
  collection: COLLECTION_NAME,
  filter: {
    _id: {
      $in:
        [
            { $oid: "61c3472a1396e0693eba124c" },
            { $oid: "61eb2496b8f08060d1dee50a" },
        ]
    }
  }
})

Available Methods

findOne

find

insertOne

insertMany

updateOne

updateMany

replaceOne

deleteOne

deleteMany

aggregate

Errors

Notes

This projects uses ESM loader, if you need commonJS please open an issue and I'll add it in for you.

Todo

Testing, better documentation, flow types or typescript.