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

warehouse.ai-status-models

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warehouse.ai-status-models - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json
{
"name": "warehouse.ai-status-models",
"version": "1.1.1",
"version": "1.2.0",
"description": "models for warehouse.ai-status-api",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,10 +19,29 @@ const Wrap = require('./wrap');

* @param {String} params.version Version for counter table
* @param {Number} amount Number to increment
* @returns {Promise} when operation complete
* @public
*/
async increment(params) {
async increment(params, amount = 1) {
const client = await this._getConnection();
const query = `UPDATE status_counter SET count=count+1 WHERE pkg=:pkg AND env=:env AND version=:version`;
const query = `UPDATE status_counter SET count=count+${amount} WHERE pkg=:pkg AND env=:env AND version=:version`;
return client.execute(query, params, { prepare: true, counter: true });
}
/**
* Decrement the given counter for this table in the manual way with the
* cassandra driver until we put this into datastar in a proper way
*
* @function increment
* @param {Object} params Parameters for performing increment
* @param {String} params.env Env for Counter table
* @param {String} params.pkg Pkg for Counter table
* @param {String} params.version Version for counter table
* @param {Number} amount Number to increment
* @returns {Promise} when operation complete
* @public
*/
async decrement(params, amount = 1) {
const client = await this._getConnection();
const query = `UPDATE status_counter SET count=count-${amount} WHERE pkg=:pkg AND env=:env AND version=:version`;
return client.execute(query, params, { prepare: true, counter: true });
}
}

@@ -29,0 +48,0 @@

@@ -199,3 +199,15 @@ const thenify = require('tinythen');

});
it('should decrement counter after increment and validate the changes', async function () {
await StatusCounter.increment(StatusCounterFixture);
const result = await StatusCounter.findOne(StatusCounterFixture);
assume(result.count).equals(1);
await StatusCounter.increment(StatusCounterFixture);
const result1 = await StatusCounter.findOne(StatusCounterFixture);
assume(result1.count).equals(2);
await StatusCounter.decrement(StatusCounterFixture, 2);
const result2 = await StatusCounter.findOne(StatusCounterFixture);
assume(result2.count).equals(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