cloudflare-mongodb
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

Cloudflare MongoDB

MongoDB Driver for Cloudflare Workers

Example

import { CloudflareMongoClient, Document } from 'cloudflare-mongodb'

type User = Document & {
  firstName: string
}

const client = new CloudflareMongoClient({
  /**
   * Proxy api url
   */
  apiServiceUrls: ['https://mongodb-proxy.g7p.io'],
  /**
   * Authentication token, keep it secured
   */
  apiAuthToken: process.env.API_AUTH_TOKEN,
})

const db = client.db('g7')
const users = db.collection<User>('users')

// Insert
const user = await users.insertOne({
  firstName: 'Ezeki',
})

// Update
await users.updateOne(
  { _id: user?.id },
  {
    $set: {
      firstName: 'EzekiX',
    },
  },
)

Package Sidebar

Install

npm i cloudflare-mongodb

Weekly Downloads

34

Version

0.1.6

License

ISC

Unpacked Size

64.1 kB

Total Files

8

Last publish

Collaborators

  • ezeki