JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 672
  • Score
    100M100P100Q112179F
  • License MIT

Reuse MongoDB connections between AWS Lambda invocations.

Package Exports

  • @1mill/mongo
  • @1mill/mongo/dist/index.cjs
  • @1mill/mongo/dist/index.module.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@1mill/mongo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@1mill/mongo

Reuse MongoDB connections between AWS Lambda invocations.

Getting started

npm install @1mill/mongo
const { Mongo } = require('@1mill/mongo')

const mongo = new Mongo({
  db: 'my-database-name',
  uri: 'mongodb://my-username:my-password@my-mong-host-name:27017/my-database-name',
})

exports.handler = async (cloudevent = {}, ctx = {}) {
  ctx.callbackWaitsForEmptyEventLoop = false

  const { db } = await mongo.connect()

  const collection = db.collection('my-collection-name')
  await collection.createIndex({ something: 1 })
  await collection.insertOne({ something: 'yes' })
}
Name Required Default Notes
db process.env.MILL_MONGO_DB
options {} useNewUrlParser and useUnifiedTopology enabled by default
uri yes process.env.MILL_MONGO_URI

Deploying

  1. Commit changes
  2. Run npm version (major|minor|patch)
  3. Run git push
  4. Run npm run deploy