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

ezobjects

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ezobjects - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

18

example-mysql.js

@@ -69,15 +69,21 @@ /** Require external modules */

/** Create a second instance of the Person object */
const person2 = new Person();
const anotherPerson = new Person();
/** Await loading of database record with ID 2 into person2 */
await person2.load(db, 2);
/** Await loading of database record with ID 1 into person2 */
await anotherPerson.load(db, 1);
/** Log the current value of person2 */
console.log(person2);
console.log(anotherPerson);
/** Set person2's checking balance to 50.74 */
person2.checkingBalance(50.74);
anotherPerson.checkingBalance(50.74);
/** Await update of person2 in database */
await person2.update(db);
await anotherPerson.update(db);
/** Delete the person at ID # 1 */
await anotherPerson.delete(db);
/** Try to load person at ID # 1 (will throw error) */
await anotherPerson.load(db, 1);
} catch ( err ) {

@@ -84,0 +90,0 @@ /** Log any caught errors */

const docket = require('docket-parser');
docket.title(`EZ Objects v2.1.1`);
docket.title(`EZ Objects v2.2.0`);
docket.linkClass('text-success');
docket.parseFiles(['index.js', 'mysql-connection.js']);
docket.generateDocs('docs');

@@ -643,2 +643,19 @@ const mysqlConnection = require('./mysql-connection');

};
/** Create MySQL delete method on prototype */
parent[obj.className].prototype.delete = async function (db) {
/** If the argument is a valid database, update database record */
if ( typeof db == 'object' && db.constructor.name == 'MySQLConnection' ) {
/** Execute query to update record in database */
await db.query(`DELETE FROM ${obj.tableName} WHERE id = ?`, [this.id()]);
}
/** Otherwise throw TypeError */
else {
throw new TypeError(`${this.constructor.name}.delete(${typeof db}): Invalid signature.`);
}
/** Allow for call chaining */
return this;
};
}

@@ -645,0 +662,0 @@ });

{
"name": "ezobjects",
"version": "2.1.1",
"version": "2.2.0",
"description": "Easy dynamic object generation with strict typing and set chaining",

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

@@ -1,2 +0,2 @@

# EZ Objects v2.1.1
# EZ Objects v2.2.0

@@ -42,3 +42,3 @@ EZ Objects is a Node.js module (that can also be usefully browserify'd) that aims to save you lots of time

/**
* Load external MySQL configuration which has the following JSON:
* Load external MySQL configuration which uses the following JSON format:
*

@@ -51,3 +51,2 @@ * {

* }
*
*/

@@ -57,4 +56,7 @@ const configMySQL = JSON.parse(fs.readFileSync('mysql-config.json'));

/**
* Connect to the MySQL database using our MySQL module async/await
* wrapper.
* Create a connection object for the MySQL database using our MySQL
* module async/await wrapper. Currently, using the ezobjects MySQL
* database is the only option, but future versions may seek to expand
* the option to other databases, or at least allow the standard mysql
* module to work.
*/

@@ -152,6 +154,6 @@ const db = new ezobjects.MySQLConnection(configMySQL);

await person.insert(db);
/** Log person (should have automatically incremented ID now) */
console.log(person);
/** Close database connection */

@@ -180,6 +182,6 @@ db.close();

Since the Person class configuration provided a `tableName` property, it will automatically have additional methods created that are
not present in a basic EZ Object. The additional methods are insert(db), load(db, id), and update(db). These methods can be used to
insert the object properties as a new MySQL record, load a MySQL record into the object properties, or update an existing MySQL record
with the object properties. Transforms can be used to adjust the values properties when they are get or set in the object, or when they
are saved or loaded from the database.
not present in a basic EZ Object. The additional methods are delete(db), insert(db), load(db, id), and update(db). These methods can
be used to delete the MySQL record corresponding to the object, insert the object properties as a new MySQL record, load a MySQL record
into the object properties, or update an existing MySQL record using the object properties. Transforms can be used to validate or
manipulate the property values when they are get or set in the object, or when they are saved or loaded from the database.

@@ -284,2 +286,4 @@ ## Various Uses of EZ Objects

#### See example.js and example-mysql.js for more!
## Module Specification

@@ -293,3 +297,3 @@

**ezobjects.createObject(obj)**
* Creates an ES6 class corresponding to the configuration outlined in `obj`, with constructor, initializer, getters, setters, and insert/load/update if `tableName` is configured
* Creates an ES6 class corresponding to the configuration outlined in `obj`, with constructor, initializer, getters, setters, and also delete, insert, load, and update if `tableName` is configured

@@ -296,0 +300,0 @@ **ezobjects.MySQLConnection(config)**

Sorry, the diff of this file is not supported yet

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