Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loopback-connector-mongodb

Package Overview
Dependencies
Maintainers
10
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-connector-mongodb - npm Package Compare versions

Comparing version 5.5.0 to 6.0.0

14

CHANGES.md

@@ -0,1 +1,15 @@

2021-03-22, Version 6.0.0
=========================
* coerce values of array defined as ObjectID type (=)
* Update mongodb to ^3.6.4 (wolrajhti)
* ci: convert from Travis to Github action ci (Agnes Lin)
* README: mention our work on 6.0 (Miroslav Bajtoš)
* [SEMVER-MAJOR] Drop support for LoopBack 3.x (Yaapa Hage)
2020-12-01, Version 5.5.0

@@ -2,0 +16,0 @@ =========================

39

lib/mongodb.js

@@ -108,2 +108,9 @@ // Copyright IBM Corp. 2012,2020. All Rights Reserved.

s.w = s.w || 1;
s.writeConcern = s.writeConcern || {
w: s.w,
wtimeout: s.wtimeout || null,
j: s.j || null,
journal: s.journal || null,
fsync: s.fsync || null,
};
s.url = s.url || generateMongoDBURL(s);

@@ -255,5 +262,2 @@ s.useNewUrlParser = s.useNewUrlParser !== false;

'authSource',
'w',
'wtimeout',
'j',
'forceServerObjectId',

@@ -283,3 +287,2 @@ 'serializeFunctions',

'compression',
'fsync',
'readPreferenceTags',

@@ -291,2 +294,3 @@ 'numberOfRetries',

'useUnifiedTopology',
'writeConcern',
// Ignored options

@@ -300,2 +304,7 @@ 'native_parser',

'db',
'w',
'wtimeout',
'j',
'journal',
'fsync',
];

@@ -1042,2 +1051,12 @@

} else {
if (isObjectIDProperty(modelCtor, propDef, cond, options)) {
if (Array.isArray(cond)) {
cond = cond.map(function(c) {
return ObjectID(c);
});
} else {
cond = ObjectID(cond);
}
}
query[k] = {};

@@ -1053,4 +1072,11 @@ query[k]['$' + spec] = cond;

if (isObjectIDProperty(modelCtor, propDef, cond, options)) {
cond = ObjectID(cond);
if (Array.isArray(cond)) {
cond = cond.map(function(c) {
return ObjectID(c);
});
} else {
cond = ObjectID(cond);
}
}
query[k] = cond;

@@ -2082,3 +2108,4 @@ }

if (typeof value === 'string' && value.match(ObjectIdValueRegex)) {
if ((typeof value === 'string' && value.match(ObjectIdValueRegex)) ||
(Array.isArray(value) && value.every((v) => v.match(ObjectIdValueRegex)))) {
if (isStoredAsObjectID(propDef)) return true;

@@ -2085,0 +2112,0 @@ else return !isStrictObjectIDCoercionEnabled(modelCtor, options);

7

package.json
{
"name": "loopback-connector-mongodb",
"version": "5.5.0",
"version": "6.0.0",
"description": "The official MongoDB connector for the LoopBack framework.",

@@ -14,3 +14,3 @@ "engines": {

"leak-detection": "make leak-detection",
"test": "nyc mocha test/*.test.js node_modules/juggler-v3/test.js node_modules/juggler-v4/test.js",
"test": "nyc mocha test/*.test.js node_modules/juggler-v4/test.js",
"lint": "eslint .",

@@ -52,5 +52,4 @@ "posttest": "npm run lint"

"eslint-config-loopback": "^13.0.0",
"juggler-v3": "file:./deps/juggler-v3",
"juggler-v4": "file:./deps/juggler-v4",
"loopback-datasource-juggler": "^3.0.0 || ^4.0.0",
"loopback-datasource-juggler": "^4.0.0",
"mocha": "^6.2.0",

@@ -57,0 +56,0 @@ "nyc": "^14.1.1",

@@ -5,2 +5,7 @@ # loopback-connector-mongodb

> We are working on a new major release 6.0. The `master` branch contains
> unreleased changes breaking backwards compatibility. Until 6.0 is released,
> we will be back-porting backwards compatible changes to `5.x` branch and
> publishing new releases from there.
## Installation

@@ -18,2 +23,14 @@

## Supported versions
**Starting from the version 6.0.0, this connector is no longer compatible with LoopBack 3. Please use the latest 5.x version in your LoopBack 3 applications.**
This module adopts the [Module Long Term Support (LTS)](http://github.com/CloudNativeJS/ModuleLTS) policy, with the following End Of Life (EOL) dates:
| Version | Status | Published | EOL | LoopBack | Juggler |
| ---------- | -------------------- | --------- | -------------------- | ---------|----------|
| 6.x | Current | Nov 2020 | Apr 2023 _(minimum)_ | 4 | 4.x |
| 5.x | Active LTS | Jun 2019 | Apr 2023 | 3, 4 | 3.x, 4.x |
| 4.x | Maintenance LTS | Nov 2018 | Apr 2021 | 3, 4 | 3.x, 4.x |
## Creating a MongoDB data source

@@ -38,28 +55,2 @@

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
Use the [Data source generator](http://loopback.io/doc/en/lb3/Data-source-generator.html) to add a MongoDB data source to your application.
The generator will prompt for the database server hostname, port, and other settings
required to connect to a MongoDB database. It will also run the `npm install` command above for you.
The entry in the application's `/server/datasources.json` will look like this:
```javascript
"mydb": {
"host": "myserver",
"port": 27017,
"url": "",
"database": "test",
"password": "mypassword",
"name": "mydb",
"user": "me",
"authSource" : "admin",
"connector": "mongodb"
}
```
Edit `datasources.json` to add any other additional properties that you require.
</details>
If your username or password contains special characters like `@`, `$` etc, encode the whole

@@ -137,26 +128,2 @@ username or password using [encodeURIComponent](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent).

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
For LB3 users, you can override the global `url` property in environment-specific data source configuration files, for example for production in `datasources.production.json`, and use the individual connection parameters `host`, `user`, `password`, and `port`. To do this, you _must_ set `url` to `false`, null, or “” (empty string).
If you set `url` to `undefined` or remove the `url` property altogether, the override will not work.
For example, for production, use `datasources.production.json` as follows (for example) to overide the `url` setting in `datasources.json:
```javascript
"mydb": {
"host": "myserver",
"port": 27017,
"url": false,
"database": "test",
"password": "mypassword",
"name": "mydb",
"user": "me",
"connector": "mongodb"
}
```
For more information on setting data source configurations for different environments, see [Environment-specific configuration](https://loopback.io/doc/en/lb3/Environment-specific-configuration.html#data-source-configuration).
</details>
### Using the mongodb+srv protocol

@@ -177,15 +144,2 @@

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
```javascript
"mydb": {
"connector": "mongodb",
"host": "myserver",
"database": "test",
"protocol": "mongodb+srv"
}
```
</details>
Note: the port is not specified when using the `mongodb+srv` protocol and will be ignored if given.

@@ -216,43 +170,2 @@

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
## Customizing MongoDB configuration for tests/examples
By default, examples and tests from this module assume there is a MongoDB server
instance running on localhost at port 27017.
To customize the settings, you can drop in a `.loopbackrc` file to the root directory
of the project or the home folder.
**Note**: Tests and examples in this project configure the data source using the deprecated '.loopbackrc' file method,
which is not supported in general.
For information on configuring the connector in a LoopBack application, please refer to [loopback.io](http://loopback.io/doc/en/lb2/MongoDB-connector.html).
The .loopbackrc file is in JSON format, for example:
{
"dev": {
"mongodb": {
"host": "127.0.0.1",
"database": "test",
"user": "youruser",
"password": "yourpass",
"port": 27017
}
},
"test": {
"mongodb": {
"host": "127.0.0.1",
"database": "test",
"user": "youruser",
"password": "yourpass",
"port": 27017
}
}
}
**Note**: user/password is only required if the MongoDB server has authentication enabled. `"authSource"` should be used if you cannot log in to your database using your credentials.
</details>
## Update Operators

@@ -268,15 +181,2 @@

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
```
Product.updateAll(
{ category: {eq: 'furniture'} // where clause goes in here },
{$max: {price: 100}},
options,
function(err, updateproducts) {
...
```
</details>
{% include tip.html content="you **will not** need the dollar sign `'$'` for operators in the Where

@@ -328,19 +228,2 @@ clause." %}

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
```js
{
"name": "User",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true,
"strictObjectIDCoercion": true
},
...
}
```
</details>
### Property scope

@@ -359,20 +242,2 @@

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
```js
"properties": {
{
"id": {
"type": "String",
"id": true,
"required":true,
"mongodb": {"dataType":"ObjectId"}
},
// ..
}
}
```
</details>
Also notice that for RELATIONS, if the primary key/source key has set to enforce ObjectId coercion

@@ -439,29 +304,2 @@ (no matter by `strictObjectIDCoercion: true` or `dataType: 'ObjectId'`). The corresponding foreign key will need to have it

<details><summary markdown="span"><strong>For LoopBack 3 users</strong></summary>
```js
{
"name": "User",
"options": {
"mongodb": {
"collection": "Custom_Collection_User", //custom name
},
},
"properties": {
{
"id": {
"type": "String",
"id": true,
"required":true,
},
"name": {
"type": "String",
"mongodb": {"fieldName": "Custom_Name"},}, //custom name
}
},
}
```
</details>
{% include important.html content="Since in MongoDB `_id` is reserved for the primary key, LoopBack **does not** allow customization of the field name for the id property. Please use `id` as is. Customizing the id property would cause errors." %}

@@ -468,0 +306,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc