• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Luciano Pellacani Franca

Serverless MongoDB HTTP API with Mongoose and Bluebird Promises

by

This example demonstrate how to use MongoDB with AWS and Serverless.

  1. Serverless MongoDB HTTP API with Mongoose and Bluebird Promises

Serverless MongoDB HTTP API with Mongoose

This example demonstrate how to use a MongoDB database with aws and serverless.

Using Mongoose ODM.

Use Cases

  • NoSQL CRUD API

Setup

npm install
serverless deploy

Usage

Set the MONGODB_URI environment variable (either in serverless.yml or your shell) to your MongoDB connection string before invoking the functions.

Create

curl -XPOST -H "Content-type: application/json" -d '{
   "name" : "John",
   "firstname" : "Doe",
   "city" : "Toronto",
   "birth" : "01/01/1990"
}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/'
{"id": "590b52ff086041000142cedd"}

READ

curl -XGET -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
[
  {
    "_id": "5905e2fbdb55f20001334b3e",
    "name": "John",
    "firstname": "Doe",
    "birth": null,
    "city": "Toronto",
    "ip": "01/01/1990",
    "__v": 0
  }
]

UPDATE

curl -XPUT -H "Content-type: application/json" -d '{
   "name" : "William",
   "firstname" : "Smith",
   "city" : "Miami",
   "birth" : "01/01/2000"
}' 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
"Ok"

DELETE

curl -XDELETE -H "Content-type: application/json" 'https://2c8cx5whk0.execute-api.us-east-1.amazonaws.com/user/590b52ff086041000142cedd'
"Ok"

Contents

  • Serverless MongoDB HTTP API with Mongoose
  • Use Cases
  • Setup
  • Usage

Related

GuidesPluginsExamplesSlack CommunitySupport