New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-mysql-js

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-mysql-js - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "easy-mysql-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Easy MySQL for NodeJS",

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

# easy-mysql-js
You can do database operations easily with this package.
You can do MySQL database operations (select, insert, update, delete, insertOrUpdate) easily with this package.

@@ -30,4 +30,6 @@ ### List of Features

### Example Usage
## Example Usage
***
## Select

@@ -40,3 +42,15 @@

const select_result = await Select('asd')
/*-----------------------------------------------------------------------------------------
--- SELECT --------------------------------------------------------------------------------
You can get records from the database with your custom sql query.
Returns an array
*/
const query = 'select * from users where id=1' // sql query
const select_result = await Select(query)
console.log(select_result)

@@ -47,3 +61,23 @@

const selectSingle_result = await SelectSingle("users",{id:1},{id:true,name:true,email:true})
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
/*-----------------------------------------------------------------------------------------
--- SELECT SINGLE -------------------------------------------------------------------------
You can get single record from the database with unique column.
NOTE: Column in where_condition must be unique or primary key.
Returns an object
*/
const table_name = "users" // your database table name
const where_condition = {id:1} // => where id=1
const return_columns = {id:true,name:true,email:true} // => select id,name,email
const selectSingle_result = await SelectSingle(table_name, where_condition, return_columns)
console.log(selectSingle_result)

@@ -54,3 +88,20 @@

const selectMulti_result = await SelectMulti("users",{},{id:true,name:true,email:true})
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
/*-----------------------------------------------------------------------------------------
--- SELECT MULTI --------------------------------------------------------------------------
You can get multi records from the database with a column.
Returns an array
*/
const where_condition2 = {name:'test'} // => where name='test'
const return_columns = {id:true,name:true,email:true} // => select id,name,email
const selectMulti_result = await SelectMulti(table_name, where_condition, return_columns)
console.log(selectMulti_result)

@@ -60,2 +111,6 @@

// Error => []
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}

@@ -74,3 +129,16 @@

const insert_result = await Insert("users",{name:"name",email:"asd@asd.com",phone:"1234567890"})
/*-----------------------------------------------------------------------------------------
--- INSERT --------------------------------------------------------------------------------
You can insert a new record to database easily with table_name and data_to_insert parameters.
Returns true or false
*/
const table_name = "users" // your database table name
const data_to_insert = {name:"name",email:"asd@asd.com",phone:"1234567890"} // your table columns
const insert_result = await Insert(table_name, data_to_insert)
console.log(insert_result)

@@ -80,2 +148,5 @@

// Error => false
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}

@@ -95,3 +166,18 @@

const update_result = await Update("users",{email:"asd@asd.com"},{email:"qwe@qwe.com"})
/*-----------------------------------------------------------------------------------------
--- UPDATE --------------------------------------------------------------------------------
You can update the record in the database with table_name, where_condition and data_to_set
parameters.
Returns true or false
*/
const table_name = "users" // your database table name
const where_condition = {email:"asd@asd.com"} // where email='asd@asd.com'
const data_to_set = {email:"qwe@qwe.com"} // set email='qwe@qwe.com'
const update_result = await Update(table_name, where_condition, data_to_set)
console.log(update_result)

@@ -101,2 +187,5 @@

// Error => false
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}

@@ -116,3 +205,22 @@

const insertOrUpdate_result = await InsertOrUpdate("users",{id:1},{phone:"123123"},{name:"name2",email:"qwe@qwe.com",phone:"1234567891"})
/*-----------------------------------------------------------------------------------------
--- INSERT OR UPDATE ----------------------------------------------------------------------
You can insert or update the record easily with table_name, where_condition, data_to_update
and data_to_insert parameters.
If the record exists then it will be updated. If the record does not exist then it will be
inserted.
Returns true or false
*/
const table_name = "users" // your database table name
const where_condition = {id:1} // where id=1
const data_to_update = {phone:"123123"} // if the record exists then update the columns
const data_to_insert = {name:"name2",email:"qwe@qwe.com",phone:"1234567891"} // if the record does not exist then add a new record
const insertOrUpdate_result = await InsertOrUpdate(table_name, where_condition, data_to_update, data_to_insert)
console.log(insertOrUpdate_result)

@@ -122,2 +230,5 @@

// Error => false
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}

@@ -137,3 +248,16 @@

const delete_result = await Delete("users",{id:1})
/*-----------------------------------------------------------------------------------------
--- DELETE --------------------------------------------------------------------------------
You can delete the records from the database with where_condition.
Returns true or false
*/
const table_name = "users" // your database table name
const where_condition = {id:1} // where id=1
const delete_result = await Delete(table_name, where_condition)
console.log(delete_result)

@@ -143,2 +267,5 @@

// Error => false
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}

@@ -145,0 +272,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