Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@keystonejs/adapter-mongoose

keystonejs1.1kMIT11.2.2TypeScript support: definitely-typed

KeystoneJS Mongoose Database adapter.

readme

Mongoose database adapter

This is the last active development release of this package as Keystone 5 is now in a 6 to 12 month active maintenance phase. For more information please read our Keystone 5 and beyond post.

View changelog

Usage

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:

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

See the Mongoose docs for a detailed list of options.

changelog

@keystonejs/adapter-mongoose

11.2.2

Patch Changes

11.2.1

Patch Changes

11.2.0

Minor Changes

Patch Changes

11.1.0

Minor Changes

  • f88f3976b #9 Thanks @timleslie! - Added support for configuring the field to use for search filtering via the searchField list adapter config option.

Patch Changes

11.0.1

Patch Changes

11.0.0

Major Changes

  • 749d1c86c #4709 Thanks @timleslie! - Database adapters no longer support custom ListAdapter classes via the listAdapterClass option of adapterConfig in createList().

Patch Changes

10.1.2

Patch Changes

10.1.1

Patch Changes

10.1.0

Minor Changes

  • 364ac9254 #4516 Thanks @renovate! - Updated dependency mongoose to ^5.11.5.

  • d329f07a5 #4536 Thanks @timleslie! - Improved performance of generated queries. Thanks to @enhancers for the code contribution and @gautamsi for leading the discussion.

Patch Changes

10.0.1

Patch Changes

10.0.0

Major Changes

Patch Changes

9.0.8

Patch Changes

9.0.7

Patch Changes

9.0.6

Patch Changes

9.0.5

Patch Changes

9.0.4

Patch Changes

9.0.3

Patch Changes

9.0.2

Patch Changes

9.0.1

Patch Changes

9.0.0

Major Changes

Patch Changes

8.1.3

Patch Changes

8.1.2

Patch Changes

8.1.1

Patch Changes

  • 63e00d80 #2973 Thanks @timleslie! - Fixed a bug which could lead to data loss (knex adapter only) when deleting items from a list which was the 1 side of a 1:N relationship.

8.1.0

Minor Changes

  • 9bad0e5f #2660 Thanks @Vultraz! - Added new sortBy query argument.

    Each list now has an additional Sort<List>By enum type that represents the valid sorting options for all orderable fields in the list. sortBy takes one or more of these enum types, allowing for multi-field/column sorting.

Patch Changes

8.0.2

Patch Changes

8.0.1

Patch Changes

8.0.0

Major Changes

  • fd685241 #2000 Thanks @timleslie! - ## Release - Arcade

    This release introduces a new and improved data schema for Keystone. The new data schema simplifies the way your data is stored and will unlock the development of new functionality within Keystone.

    Important: You will need to make changes to your database to take advantage of the new data schema. Please read the full release notes for instructions on updating your database.

Patch Changes

7.0.0

Major Changes

  • 2ae2bd47 #2623 Thanks @maryam-mv! - Updated @sindresorhus/slugify to fix a problem where it was producing unexpected output, eg. adding unexpected underscores: 'NAME1 Website' => 'nam_e1_website'. The slugify output for db name may be different with this change. For the above example, the output will now be 'name_1_website' for the same string.

    If your database name changes unexpectedly, you can add an environment variable called DATABASE_URL with a full path to the database. For more information on configuring database connections read the documentation for the Knex adapter or Mongoose adapter.

    If you are using the Slug field type, in some edge-cases, slugs may change when saved after this update. You can use the generate option on the slug field for custom slug generation if required.

Patch Changes

6.0.0

Major Changes

  • cec7ba5e #2544 Thanks @timleslie! - Removed the prepareFieldAdapter() method of BaseListAdapter, MongooseAdapter and KnexListAdapter. No action is required unless you were explicitly using this method in your code.

Minor Changes

  • ca28681c #2543 Thanks @timleslie! - BaseKeystoneAdapter.connect and BaseKeystoneAdapter.postConnect both now accept a rels argument, which provides information about the relationships in the system.

Patch Changes

5.2.2

Patch Changes

5.2.1

Patch Changes

5.2.0

Minor Changes

Patch Changes

5.1.5

Patch Changes

5.1.4

Patch Changes

5.1.3

Patch Changes

5.1.2

Patch Changes

5.1.1

Patch Changes

5.1.0

Minor Changes

Patch Changes

5.0.1

Patch Changes

  • 3c19cddd #1838 Thanks @jesstelford! - Adding a new Relationship field when using the Mongoose adapter will no longer cause an "$in needs an array" error to be thrown.

5.0.0

Major Changes

  • 7b4ed362 #1821 Thanks @jesstelford! - Release @keystonejs/* packages (つ^ ◡ ^)つ

    • This is the first release of @keystonejs/* packages (previously @keystone-alpha/*).
    • All packages in the @keystone-alpha namespace are now available in the @keystonejs namespace, starting at version 5.0.0.
    • To upgrade your project you must update any @keystone-alpha/* dependencies in package.json to point to "@keystonejs/*": "^5.0.0" and update any require/import statements in your code.

Patch Changes

@keystone-alpha/adapter-mongoose

6.0.1

Patch Changes

6.0.0

Major Changes

  • 6d7d0df0 #1729 Thanks @timleslie! - This change significantly changes how and when we populate many-relationships during queries and mutations. The behaviour of the GraphQL API has not changed, but queries should be more performant, particularly for items with many related items. The existingItem parameter in hooks will no longer have the many-relationship fields populated. List.listQuery() no longer populates many relationship fields. For most users there should not need to be any changes to code unless they are explicitly relying on a many-relationship field in a hook, in which case they will need to execute an explicit query to obtain the desired values.

Patch Changes

5.0.0

Major Changes

  • b96a3a58: Remove .queryBuilder property of the MongooseListAdapter.

Patch Changes

  • 4e6a574d: Internal refactor to inline the logic which was previously computed by getRelationshipQueryCondition().
  • a48ff0a3: Internal refactor to move defintion of modifierConditions closer to where they're used.
  • 82dfef03: Move tokenizer functions out of this package and into mongo-join-builder.

  • Updated dependencies da4013e4:

  • Updated dependencies 157a439d:

4.0.8

Patch Changes

  • 9b532072: Rename Keystone to KeystoneJS in docs where possible in docs
  • a7a9249b: Internal refactor

4.0.7

4.0.6

4.0.5

Patch Changes

4.0.4

4.0.3

4.0.2

4.0.1

4.0.0

Major Changes

  • 144e6e86: - API Changes to Adapters: - Configs are now passed directly to the adapters rather than via adapterConnectOptions. - Default connections strings changed for both Knex and Mongoose adapters to be more inline with system defaults. - keystone.connect() no longer accepts a to paramter - the connection options must be passed to the adapter constructor (as above).

3.0.1

Patch Changes

  • ba146456: Depend on correct version of @keystone-alpha/fields-mongoid

3.0.0

Major Changes

  • 42c3fbc9: Adding isIndexed field config and support for in most field types
  • 42c3fbc9: Switching lists to use standard field types for primary keys (instead of weird pseudo-field)

Patch Changes

2.2.1

2.2.0

Minor Changes

2.1.0

Minor Changes

  • 3958a9c7:

    Removed the isRequired parameter from MongooseFieldAdapter.buildValidator()

Patch Changes

2.0.1

2.0.0

Major Changes

  • 9a0456ff:

    Removing 'dbName' config option

1.0.7

Patch Changes

1.0.6

  • [patch]06464afb:

    • Simplify internal APIs

1.0.5

1.0.4

1.0.3

1.0.2

  • [patch]11c372fa:

    • Update minor-level dependencies
  • [patch]619b17c2:

    • Reformat code using latest version of Prettier (1.16.4)
  • [patch]7417ea3a:

    • Update patch-level dependencies

1.0.1

  • [patch]6ba2fd99:

    • Mongoose option useFindAndModify is defaulted to false, resolves deprecation warnings
  • [patch]1f0bc236:

    • Update the package.json author field to "The Keystone Development Team"
  • [patch]9534f98f:

    • Add README.md to package

1.0.0

  • [major] 8b6734ae:

    • This is the first release of keystone-alpha (previously voussoir). All packages in the @voussoir namespace are now available in the @keystone-alpha namespace, starting at version 1.0.0. To upgrade your project you must update any @voussoir/<foo> dependencies in package.json to point to @keystone-alpha/<foo>: "^1.0.0" and update any require/import statements in your code.

@voussoir/adapter-mongoose

2.0.1

  • [patch] 6fa810f7:

    • Rename @voussoir/core -> @voussoir/keystone. This is to free up the @voussoir/core package for a different purpose, and make the main import for new Keystone projects be @voussoir/keystone. The exports have stayed the same.
  • [patch] 113e16d4:

    • Remove unused dependencies
  • [patch] b155d942:

    • Update mongo/mongoose dependencies

2.0.0

  • [minor] 5f891cff:

    • Add a setupHooks method to BaseFieldAdapter
  • [major] 53e27d75:

    • Removes methods from Mongoose adapter classes: getFieldAdapterByQueryConditionKey, getSimpleQueryConditions, getRelationshipQueryConditions, getQueryConditions, getRelationshipQueryConditions, getRefListAdapter, hasQueryCondition.
  • [patch] 797dc862:

    • Move itemsQueryMeta onto the base adapter class
  • [major] 6471fc4a:

    • Remove mapsToPath method from MongooseListAdapter
  • [major] 48773907:

    • Move findFieldAdapterForQuerySegment onto the BaseListAdapter
  • [major] 860c3b80:

    • Add a postConnect method to list adapters to capture all the work which needs to be done after the database has been connected to
  • Updated dependencies [723371a0]:

  • Updated dependencies [aca26f71]:
  • Updated dependencies [a3d5454d]:

1.0.0

  • [patch] 21626b66:

    • preSave/postRead item hooks run consistently
  • [patch] 929b177c:

    • Enable sorting on DateTime fields
  • [major] 01718870:

    • Field configuration now tasks isRequired and isUnique, rather than required and unique
  • [patch] fc1a9055:

    • Update dependencies to latest patch versions
  • Updated dependencies [c83c9ed5]:

  • Updated dependencies [c3ebd9e6]:
  • Updated dependencies [ebae2d6f]:
  • Updated dependencies [78fd9555]:
  • Updated dependencies [d22820b1]:

0.5.0

  • [patch] ff4b98c5:

    • Consolidate mongoose schema pre/post hooks for field types
  • [minor] 9c383fe8:

    • Always use $set and { new: true } in the mongoose adapter update() method
  • [minor] b0d19c24:

    • Use consistent query condition builders across all field types
  • Updated dependencies [45d4c379]:

0.4.1

0.4.0

  • [minor] 47c7dcf6" :

    • Bump all packages with a minor version to set a new baseline
  • Updated dependencies [d94b517]:

  • Updated dependencies [a3b995c]:

0.3.2

0.3.1

0.3.0

0.2.0

  • [minor] Add missing dependencies for which the mono-repo was hiding that they were missing fed0cdc

0.1.2

  • [patch] Rename readme files a8b995e

0.1.1

  • [patch] Remove tests and markdown from npm dc3ee7d