Socket
Socket
Sign inDemoInstall

node-red-contrib-orm-objection

Package Overview
Dependencies
315
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

6

CHANGELOG.md

@@ -0,3 +1,7 @@

## 1.1.0 (2020-10-21)
- Added patch and orderBy features
## 1.0.0 (2020-10-21)
- 🎉 First version
- First version

2

package.json

@@ -35,3 +35,3 @@ {

},
"version": "1.0.0"
"version": "1.1.0"
}

@@ -25,9 +25,25 @@ # node-red-contrib-orm-objection

### Select
* Insert a `storage/Objection ORM` into your Flow and configure the database connection.
* Optionnaly select a Model name (or use `msg.topic` in the incoming message)
* Optionnaly select the [graph](https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#withgraphfetched) to be fetched along with the model (or use `msg.graph` in the incoming message)
* Optionnaly select a Model name (or use `msg.topic` in the incoming message).
* Optionnaly select the [graph](https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#withgraphfetched) to be fetched along with the model (or use `msg.graph` in the incoming message).
The incoming message may contains the following properties:
* `where`: an [**object**](http://knexjs.org/#Builder-where) representing the WHERE clause
* `where`: an [**object**](http://knexjs.org/#Builder-where) representing the WHERE clause.
* `byId`: an integer or a String that will be used in the [`findById()`](https://vincit.github.io/objection.js/api/query-builder/find-methods.html#findbyid) method.
* `orderBy`: a String to choose on which column the results should be sorted on.
### Patch (update)
* Insert a `storage/Objection ORM` into your Flow and configure the database connection.
* Select a Model name.
* Optionnaly select the [graph](https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#withgraphfetched) to be fetched along with the model (or use `msg.graph` in the incoming message).
The incoming message must contain the following property:
* `patch`: an object with the 2 properties:
* `id`: ID of the model to patch
* `props`: object containing the properties to update

@@ -94,3 +94,2 @@ module.exports = (RED) => {

const modelName = msg.topic || config.model;
console.log(modelName);
if (!models[modelName]) {

@@ -103,2 +102,3 @@ this.error(`msg.topic must contain a valid Model name (received: "${modelName}").`);

let qb = models[modelName].query(knex);
if (msg.byId) {

@@ -109,2 +109,11 @@ qb.findById(msg.byId);

}
if (msg.patch && msg.patch.id && msg.patch.props) {
qb.patchAndFetchById(msg.patch.id, msg.patch.props);
}
if (msg.orderBy) {
qb.orderBy(msg.orderBy);
}
const graph = msg.graph || config.graph;

@@ -111,0 +120,0 @@ if (graph) {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc