Socket
Socket
Sign inDemoInstall

sqlite-express

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlite-express - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

modules/count.js

10

index.js

@@ -48,2 +48,12 @@ const path = require( 'path' );

} ) };
exist( ...params ){ return onOperation( {
method : 'exist',
parameters : params,
context : this
} ) };
count( ...params ){ return onOperation( {
method : 'count',
parameters : params,
context : this
} ) };
}

@@ -50,0 +60,0 @@

8

modules/methods.js

@@ -6,2 +6,4 @@ const createTable = require( './table' );

const deleteDB = require( './delete' );
const exist = require( './exist' );
const count = require( './count' );

@@ -13,3 +15,5 @@ module.exports = {

update : updateDB,
delete : deleteDB
}
delete : deleteDB,
exist : exist,
count : count
};

@@ -11,3 +11,5 @@ const is = require( './submodules/is' );

update : [ 'db', 'table', 'update', 'where', 'connector', 'logQuery' ],
delete : [ 'db', 'table', 'where', 'connector', 'logQuery' ]
delete : [ 'db', 'table', 'where', 'connector', 'logQuery' ],
exist : [ 'db', 'table', 'where', 'conector', 'logQuery' ],
count : [ 'db', 'table', 'where', 'conector', 'logQuery' ]
};

@@ -14,0 +16,0 @@ let [ methodDefaults, correctParams ] = [ {}, {} ];

{
"name": "sqlite-express",
"version": "3.0.3",
"version": "3.0.4",
"description": "functions for sqlite3",

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

@@ -409,2 +409,82 @@ ### SQLite-Express Version 3

# since version 3.0.4 we have two new methods: 'exist' and 'count'.
## exist
The `exist` method is used to find out if there is a row in a table that meets a given condition, or not. It returns a Promise that resolves to a boolean. It requires as parameters the database as a string, the table name as a string, the condition as a where object and a connector if desired.
### Usage
to check if there is at least one row that meets the condition you can use the following syntax:
```javascript
async function theData() {
console.log(await session.exist('dataBase1', "the_table", {name: "Alex"}));
}
theData();
```
or
```javascript
const objectToQuery = {
db: 'dataBase1',
table: "the_table",
where: {name: "Alex"}
}
async function theData() {
console.log(await session.exist(objectToQuery));
}
theData();
```
You can also use `.then` for handling the Promise:
```javascript
session.exist(objectToQuery).then(data => {
console.log(data);
});
```
if in the table 'the_table' of the database 'dataBase1' there is at least one row whose column 'name' has as value 'Alex'. The code will return a promise that will resolve to true, if on the contrary, there is no row that meets this condition, the returned promise will resolve to false.
## count
The `count` method is used to know the number of rows that meet a condition. It returns a Promise that resolves to a number. It requires as parameters the database as a string, the table name as a string, the condition as a where object and a connector if desired.
### Usage
to know the number of rows that meet a condition you can use the following syntax:
```javascript
async function theData() {
console.log(await session.count('dataBase1', "the_table", {name: "Alex"}));
}
theData();
```
or
```javascript
const objectToQuery = {
db: 'dataBase1',
table: "the_table",
where: {name: "Alex"}
}
async function theData() {
console.log(await session.count(objectToQuery));
}
theData();
```
You can also use `.then` for handling the Promise:
```javascript
session.count(objectToQuery).then(data => {
console.log(data);
});
```
This code will check the table 'the_table' in the database 'dataBase1' and will count the rows whose value in the column 'name' is 'Alex'. Then it will return a promise that will be resolved to the number found.
## Recommendations

@@ -450,3 +530,5 @@

update: ['db', 'table', 'update', 'where', 'connector', 'logQuery'],
delete: ['db', 'table', 'where', 'connector', 'logQuery']
delete: ['db', 'table', 'where', 'connector', 'logQuery'],
exist: ['db', 'table', 'where', 'conector', 'logQuery'],
count: ['db', 'table', 'where', 'conector', 'logQuery']
}

@@ -453,0 +535,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