MongoDB adapter for Sails.js / Waterline ORM.
Sails.js/Waterline adapter for MongoDB. (See compatibility for more details.)
Provides easy access to MongoDB from Sails.js & Waterline. This module is a Sails/Waterline adapter maintained by the core team. Its goal is to provide robust, easy-to-use access to MongoDB from Sails.js and Waterline.
As an adapter, this module implements a set of declarative interfaces, conventions, and best-practices for integrating with Mongo databases. Strict adherence to an adapter specification enables the (re)use of built-in generic test suites, standardized documentation, reasonable expectations around the API for your users, and overall, a more pleasant development experience for everyone.
To install this adapter, run:
$ npm install sails-mongo
Then connect the adapter to one or more of your app's datastores.
Visit Models & ORM in the docs for more information about using models, datastores, and adapters in your app/microservice.
This version of the adapter has been tested with MongoDB versions 3.6, 4.0, and 4.2.
This adapter implements the following methods:
| Method | Status | Layer | |:---------------------|:------------------|:--------------| | ~~registerDatastore~~| ~~Implemented~~ | N/A | | ~~teardown~~ | ~~Implemented~~ | N/A | | validateModelDef | Implemented | Modeled | | createRecord | Implemented | Modeled (DML) | | createEachRecord | Implemented | Modeled (DML) | | updateRecords | Implemented | Modeled (DML) | | destroyRecords | Implemented | Modeled (DML) | | findRecords | Implemented | Modeled (DQL) | | join | not supported | Modeled (DQL) | | countRecords | Implemented | Modeled (DQL) | | sumRecords | Implemented | Modeled (DQL) | | avgRecords | Implemented | Modeled (DQL) | | definePhysicalModel | Implemented | Migratable | | dropPhysicalModel | Implemented | Migratable | | setPhysicalSequence | not supported | Migratable |
Please observe the guidelines and conventions laid out in the Sails project contribution guide when opening issues or submitting pull requests.
This repository includes a Docker Compose file that helps setting up the environment needed to run the test.
npm testcommand expects a local MongoDB instance running.
For convenience, some new npm scripts are available: -
npm run start-mongodb: Starts MongoDB docker instance -
npm run stop-mongodb: Stops MongoDB docker instance -
npm run mongodb-shell: Runs the MongoDB shell CLI, connects to the instance started by the
npm run start-mongodbcommand.
This simplifies development as you do not need to have a MongoDB instance running on the development computer.
Notice that if you do have a local MongoDB instance, then, there might be port conflicts if you run the docker version. The docker version is configured to run on the standard port 27017.
The normal development workflow would now be: - When starting a development session,
npm run start-mongdb- Now we can execute
npm testas many times as needed - When finishing a development session,
npm run stop-mongdb
npm run docker-testcommand runs the tests on a single run under the latest MongoDB version (at the time 4.2). It automatically starts a MongoDB docker instance, and it stops it. This is useful for one time local tests. Note that since this command stops MongoDB,
npm testwill fail.
When running automation tests in Travis, the module is tested under a combination of Node.js 10, 12, 14 and MongoDB: 3.6, 4.0, 4.2.
When running automation tests in AppVeyor, the module is tested under a combination of Node.js 10, 12, 14 and the MongoDB version that AppVeyor supports. Multiple MongoDB version are not tested in AppVeyor.
For more information, check MongoDB's Support Policy.
To run tests while developing, you can run
npm run docker. This command opens a docker instance and opens a shell. From there you can run
npm testto run the tests as many times as you need.
To report a bug, click here.
This core adapter is available under the MIT license.