• Stars
    star
    411
  • Rank 105,247 (Top 3 %)
  • Language
    JavaScript
  • Created almost 12 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MongoDB adapter for Sails.js / Waterline ORM.

Node.js and MongoDB on Sails.js/Waterline

sails-mongo

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.

Installation

To install this adapter, run:

$ npm install sails-mongo

Then connect the adapter to one or more of your app's datastores.

Usage

Visit Models & ORM in the docs for more information about using models, datastores, and adapters in your app/microservice. For a low-level usage example, check out the tutorial.

Compatibility

This version of the adapter has been tested with MongoDB versions 3.6, 4.0, and 4.2. It uses MongoDB 3.5.x connection options. If you're upgrading from an older version, note that there are some updated, changed, new and deprecated options.

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

Questions?

See Extending Sails > Adapters > Custom Adapters in the Sails documentation, or check out recommended support options.

Contributing   Build Status   Build status on Windows

Please observe the guidelines and conventions laid out in the Sails project contribution guide when opening issues or submitting pull requests.

NPM

Development and Test

This repository includes a Docker Compose file that helps setting up the environment needed to run the test.

The npm test command 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-mongodb command.

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 test as many times as needed
  • When finishing a development session, npm run stop-mongdb

The npm run docker-test command 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 test will 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 test to run the tests as many times as you need.

Special thanks

Thanks so much to Ted Kulp (@tedkulp) and Robin Persson (@prssn) for building the first version of this adapter back in 2013. Since then, it has evolved into a core adapter within the framework.

Bugs   NPM version

To report a bug, click here.

License

This core adapter is available under the MIT license.

As for Waterline and the Sails framework? They're free and open-source under the MIT License.

© The Sails Co.

image_squidhome@2x.png

More Repositories

1

sails

Realtime MVC Framework for Node.js
JavaScript
22,811
star
2

waterline

An adapter-based ORM for Node.js with support for mysql, mongo, postgres, mssql (SQL Server), and more
JavaScript
5,412
star
3

sails-docs

**Latest docs now live in the Sails core repo!** The source markdown files for the official Sails.js documentation, which gets compiled, squeezed, and stretched into HTML when we deploy the Sails website.
778
star
4

waterline-docs

WARNING: The content in this repo is out of date! See https://github.com/balderdashy/sails-docs for the most up-to-date documentation
452
star
5

sails-mysql

MySQL adapter for Sails.js/Waterline
JavaScript
193
star
6

angularSails

AngularJS bindings for Sails. http://angularjs.org
JavaScript
184
star
7

sails.io.js

Browser SDK for communicating w/ Sails via sockets
JavaScript
182
star
8

sails-postgresql

PostgreSQL adapter for Sails.js
JavaScript
167
star
9

sails-redis

Lightweight Redis adapter for Node.js/Sails apps, focused on providing easy direct access to the configured, connected, ready-to-use Redis client instance. (Useful for caching.)
JavaScript
129
star
10

seed

A sample application generated by Sails.
JavaScript
91
star
11

mast

UI conventions built on top of Backbone.JS
JavaScript
81
star
12

sails-hook-email

Sails email hook
JavaScript
67
star
13

backbone-to-sails

Backbone SDK for communicating with Sails.js over Socket.io
JavaScript
64
star
14

skipper-s3

Streaming file uploads to S3
JavaScript
62
star
15

include-all

An easy way to include all files within a directory. Note: This is a fork of felixge's require-all which allows for optional includes.
JavaScript
56
star
16

sails-adapter-boilerplate

Example of a custom adapter (i.e. ORM plugin) for Waterline / Sails.js
JavaScript
45
star
17

sails-disk

Development-only persistent adapter for Sails.js / Waterline
JavaScript
44
star
18

captains-log

Lightweight logger with a simple pass-through configuration for use with fancier logging libraries. Used by the Sails framework. Optional support for colorized output, custom prefixes, and log levels (using npm's logging conventions.)
JavaScript
44
star
19

waterline-schema

This is the core schema builder used in the Waterline ORM.
JavaScript
33
star
20

activity-overlord-2-preview

A preview of Irl Nathan's Activity Overlord 2.0 (complete tutorial of Sails w/ Angular 1)
JavaScript
31
star
21

sails-generate

Master of ceremonies for generators in the Sails CLI
JavaScript
28
star
22

sails-generate-frontend

Generate the frontend part of a new Sails app.
JavaScript
26
star
23

sails-memory

In-memory, non-persistent adapter for Sails.js / Waterline
JavaScript
24
star
24

sails-hook-sockets

Implements socket.io support in Sails.
JavaScript
23
star
25

sails-hook-dev

A Sails hook that provides diagnostic / debugging information and levers during development.
JavaScript
22
star
26

sails-angular-seed

Boilerplate AngularJS app with Sails
JavaScript
21
star
27

enpeem

Lightweight wrapper for accessing npm programmatically (alternative to adding `npm` as a dependency)
JavaScript
19
star
28

sails-hook-orm

Implements support for Waterline ORM in Sails.
JavaScript
18
star
29

sails-hook-subapps

Sails hook for including child Sails apps into a parent app
JavaScript
18
star
30

sails-generate-generator

Generate a custom generator for Sails.js
JavaScript
18
star
31

merge-defaults

A recursive version of `_.defaults`.
JavaScript
16
star
32

waterline-adapter-tests

API integration tests for Waterline adapters
JavaScript
16
star
33

waterline-sequel

A SQL generator for use in Waterline Adapters
JavaScript
16
star
34

skipper-disk

Streaming file uploads to a server's local filesystem
JavaScript
14
star
35

sails-twitter

Twitter adapter for Sails.js
JavaScript
14
star
36

waterline-criteria

Utility library for use in Sails adapters where you need to filter a list of output using a criteria object
JavaScript
13
star
37

sails-generate-views-jade

Generate default views for a Sails app using Jade templates
HTML
11
star
38

billable

Tracks billable hours.
JavaScript
10
star
39

sails-generate-adapter

Generate a waterline/sails.js adapter.
JavaScript
10
star
40

fixture-stdout

A test fixture to intercept writes to stdout.
9
star
41

sails-generate-backend

Generate the backend part of a new Sails app.
JavaScript
9
star
42

sails-generate-new

Generate a new Sails app.
JavaScript
8
star
43

sails-riak

Riak adapter for Sails.js
CoffeeScript
7
star
44

machinepack-youtube

Communicate with the Youtube API to get video views, etc.
JavaScript
6
star
45

deretina

For supporting retina displays on the web: downsizes @2x images in the current directory
JavaScript
6
star
46

example-sails-proj-with-angular

JavaScript
6
star
47

sails-irc

IRC adapter for Sails.js
JavaScript
6
star
48

sails-generate-model

Generate a model in a Sails app.
JavaScript
5
star
49

sails-build-dictionary

DEPRECATED in Sails v1.0 (instead, just use [email protected] directly)
JavaScript
5
star
50

machinepack-slack

Use the Slack API from Node.js.
JavaScript
5
star
51

alcohol

Makes your dates prettier
4
star
52

sails-generate-api

API generator for Sails
JavaScript
4
star
53

booty

CoffeeScript
4
star
54

sails-util

Shared utilities between sails, waterline, etc.
JavaScript
4
star
55

sails-dirty

Sails.js adapter for @felixge's node-dirty
JavaScript
3
star
56

sails-elastic-search

Elastic Search Adapter for Sails JS
3
star
57

htassets

A mobile-compatible makeover for the default apache directory listing
JavaScript
3
star
58

Mobile-HTML-5-Video-Example

Cross-platform mobile video player using HTML 5
3
star
59

express-with-shared-mongo-session-example

An example of using a shared session in Express with MongoDB as the storage container
JavaScript
2
star
60

sails-generate-views

Generate default views for a Sails app
HTML
2
star
61

dev-workshop-conf

JavaScript
2
star
62

UserSwarm

JavaScript
2
star
63

sails-generate-controller

Generate a new controller file in an existing Sails app.
JavaScript
2
star
64

sails-generate-sails.io.js

Generate a sails.io.js browser SDK file at ./assets/js/dependencies/sails.io.js.
JavaScript
2
star
65

skipper-adapter-tests

Generic acceptance tests for Skipper adapters
JavaScript
1
star
66

waterline-cursor

Association/subquery helper
JavaScript
1
star
67

sails-generate-gruntfile

Generate gruntfile for a sails app.
JavaScript
1
star
68

stubble

A trimmed-down mustache.js for jQuery
JavaScript
1
star
69

sails-generate-hook

Generate a custom hook for Sails.js.
JavaScript
1
star
70

Naked

Chrome extension that opens links with stylesheets disabled for privacy.
1
star
71

sails-stringfile

translated/localized stringfiles containing messages from Sails core and dependencies
JavaScript
1
star
72

blueprint-api-example

An example of a Sails app using a blueprint API for use in "Run in Postman" buttons on the Sails website.
JavaScript
1
star
73

waterline-blob

Factory which generates waterline adapter definitions from blob definitions (eventually merge into waterline core)
JavaScript
1
star