
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@embedvr/mongodb-data-api
Advanced tools
MongoDB Atlas Data API SDK for Node.js and V8 Isolate environments like Cloudflare Workers.
Fixes a bug with aggregation.
npm i @embedvr/mongodb-data-api
or
yarn add @embedvr/mongodb-data-api
import { createMongoDBDataAPI, Region } from '@embedvr/mongodb-data-api'
// init by URL Endpoint
const api = createMongoDBDataAPI({
apiKey: '<your_mongodb_api_key>',
urlEndpoint: 'https://data.mongodb-api.com/app/<your_mongodb_app_id>/endpoint/data/beta'
})
// or init by app ID
const api = createMongoDBDataAPI({
apiKey: '<your_mongodb_api_key>',
appId: '<your_mongodb_app_id>'
})
// specific region of app
const api = createMongoDBDataAPI({
apiKey: '<your_mongodb_api_key>',
appId: '<your_mongodb_app_id>',
region: Region.Virginia
})
See MongoDB Data API Resources.
api.findOneapi.findapi.insertOneapi.insertManyapi.updateOneapi.updateManyapi.replaceOneapi.deleteOneapi.deleteManyapi.aggregateapi
.findOne({
dataSource: '<target_cluster_name>',
database: '<target_database_name>',
collection: '<target_collection_name>',
filter: { name: 'Surmon' }
})
.then((result) => {
console.log(result.document)
})
api
.insertOne({
dataSource: '<target_cluster_name>',
database: '<target_database_name>',
collection: '<target_collection_name>',
document: {
name: 'Surmon',
age: 19
}
})
.then((result) => {
console.log(result.insertedId)
})
api
.aggregate({
dataSource: '<target_cluster_name>',
database: '<target_database_name>',
collection: '<target_collection_name>',
pipeline: [
{ $match: { status: 'urgent' } },
{ $group: { _id: '$productName', sumQuantity: { $sum: '$quantity' } } }
]
})
.then((result) => {
console.log(result.documents)
})
// select cluster
const clusterA = api.$cluster('a')
// select database
const databaseB = clusterA.$database('b')
// select collection
const collectionC = databaseB.$collection<C>('c')
// data actions
const data = await collectionC.findOne({
filter: {
/*...*/
}
})
const result = await collectionC.insertOne({
document: {
/*...*/
}
})
// -------------
// chaining is equivalent to the api call
api.$cluster('a').$database('b').$collection<C>('c').findOne({ filter: {} })
// the same as
api.findOne<C>({
dataSource: 'a',
database: 'b',
collection: 'c',
filter: {}
})
You can specific the action request to prevent this package from lagging relative to the official one.
api.$$action('findOne', {
dataSource: '...',
database: '...',
collection: '...',
filter: {}
})
You can use the original Class to implement some special requirements.
import { MongoDBDataAPI } from 'mongodb-data-api'
const customerCollection = new MongoDBDataAPI<CustomerDocument>(
{
apiKey: '<your_mongodb_api_key>',
appId: '<your_mongodb_app_id>'
},
{
dataSource: '<target_cluster_name>',
database: '<target_database_name>',
collection: '<target_collection_name>'
}
)
const customer = await customerCollection.findOne({ ... })
# install dependencies
yarn
# lint
yarn lint
# test
yarn test
# build
yarn build
Detailed changes for each release are documented in the release notes.
FAQs
MongoDB atlas data API SDK for CF Workers
We found that @embedvr/mongodb-data-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.