https://github.com/drivly/mongo-fetch
Fetch-based Mongo Client for the Edge (Including Cloudflare Workers, Vercel Edge Functions, Deno, etc), the Browser, or Node that is API Compatible with the official `mongodb` NodeJS driver
https://github.com/drivly/mongo-fetch
Last synced: 5 months ago
JSON representation
Fetch-based Mongo Client for the Edge (Including Cloudflare Workers, Vercel Edge Functions, Deno, etc), the Browser, or Node that is API Compatible with the official `mongodb` NodeJS driver
- Host: GitHub
- URL: https://github.com/drivly/mongo-fetch
- Owner: drivly
- License: mit
- Created: 2023-02-22T09:57:35.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-01T06:04:27.000Z (over 1 year ago)
- Last Synced: 2024-12-24T02:49:47.921Z (5 months ago)
- Language: JavaScript
- Size: 94.7 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mongo Fetch Client - Data API driver
This client is a HTTP adapter for the Data API, allowing you to access data as if you were connecting to a MongoDB database directly. While it is not a full replacement for the MongoDB driver, it does provide a way to access MongoDB from a browser or edge-computing service like Cloudflare Workers.
## Usage
```js
import { MongoFetchClient } from 'mongo-fetch'const client = new MongoFetchClient(
'clusterName', // The cluster name in our self-hosted Data API, otherwise this is the dataSource.
{
url: 'https://data-api.example.com',
apiKey: 'secret' // API key for authenticating with the API
}
)const documents = await client
.db('database')
.collection('collection')
.find({ name: 'John' })
.limit(2)
.sort({ age: -1 })
.project({ name: 1, age: 1 })
.toArray()
```## Documentation
Since this driver is a close match for the MongoDB driver, you can use the official MongoDB documentation for reference. The only difference is that you will need to use the `MongoFetchClient` class instead of the `MongoClient` class. You can find the [documentation here](https://mongodb.github.io/node-mongodb-native/5.1/classes/Collection.html).Heres a list of operations that are supported:
- find
- findOne
- insertOne
- insertMany
- updateOne
- updateMany
- deleteOne
- deleteMany
- aggregate## Notice
This driver is not 100% compatible with the MongoDB driver. As of right now, this driver only supports basic CRUD, aggregation, and index operations. It does not support transactions, change streams, or other advanced features. As our self-hosted Data API grows, we will add further features to this driver.