Skip to content
KeystoneJS LogoKeystoneJS

Mongoose database adapter

Usage

JS
const { MongooseAdapter } = require('@keystonejs/adapter-mongoose');

const keystone = new Keystone({
  adapter: new MongooseAdapter({...}),
});

Config

mongoUri (required)

This is used as the uri parameter for mongoose.connect().

Default: Environment variable (see below) or 'mongodb://localhost/<DATABASE_NAME>'

If not specified, KeystoneJS will look for one of the following environment variables:

  • CONNECT_TO
  • DATABASE_URL
  • MONGO_URI
  • MONGODB_URI
  • MONGO_URL
  • MONGODB_URL
  • MONGOLAB_URI
  • MONGOLAB_URL

Mongoose options (optional)

Additional Mongoose config options are passed directly through to mongoose.connect().

Default:

JS
{
  useNewUrlParser: true,
  useFindAndModify: false,
  useUnifiedTopology: true,
}

See the Mongoose docs for a detailed list of options.

On this page

  • Usage
  • Config
  • mongoUri (required)
  • Mongoose options (optional)
Edit on GitHub