Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ph4ntomiki/mongodb-data-api-client

PH4NTOMiki11ISC0.0.7

MongoDB Data API Client

mongodb, api, client, data, data-api, data-api-client, data-api-client-mongodb, MongoDB Atlas

readme

The package that uses MongoDB Atlas Data API to access your data

First you need to get an API key and App ID for the service, explained how here.

After that import/require the package and use it like this:

const MongoClient = require('@ph4ntomiki/mongodb-data-api-client');
const client = MongoClient('app_id', 'api_key', 'clusterName'); //cluster defaults to 'Cluster0'
const db = client.db('dbName');
const collection = db.collection('collectionName');

const results = await collection.find({title: /a/i});

You can also create client with custom fetch implementation, like for ex. for Cloudflare Workers like this:

const client = MongoClient('app_id', 'api_key', 'clusterName', {'fetch': fetch.bind(self)});

Or if you want default clusterName you can pass undefined or null at that place.