ezobjects-mysql
Advanced tools
Comparing version 11.2.4 to 11.5.0
@@ -67,24 +67,24 @@ const ezobjects = require(`./index`); | ||
/** | ||
* Create a new UserAccount called `userAccount`, initializing with | ||
* plain object passed to constructor. | ||
*/ | ||
const userAccount = new UserAccount({ | ||
username: `richlowe`, | ||
firstName: `Rich`, | ||
lastName: `Lowe`, | ||
checkingBalance: 4.32, | ||
permissions: [1, 3, 5], | ||
favoriteDay: new Date(`01-01-2018`) | ||
}); | ||
/** | ||
* Test if `userAccount` is an instance of DatabaseRecord using | ||
* the included `instanceOf` helper function. | ||
*/ | ||
console.log(ezobjects.instanceOf(userAccount, `DatabaseRecord`)); | ||
/** Let's use a self-executing async wrapper so we can await results */ | ||
(async () => { | ||
try { | ||
/** | ||
* Create a new UserAccount called `userAccount`, initializing with | ||
* plain object passed to constructor. | ||
*/ | ||
const userAccount = new UserAccount({ | ||
username: `richlowe`, | ||
firstName: `Rich`, | ||
lastName: `Lowe`, | ||
checkingBalance: 4.32, | ||
permissions: [1, 3, 5], | ||
favoriteDay: new Date(`01-01-2018`) | ||
}); | ||
/** | ||
* Test if `userAccount` is an instance of DatabaseRecord using | ||
* the included `instanceOf` helper function. | ||
*/ | ||
console.log(ezobjects.instanceOf(userAccount, `DatabaseRecord`)); | ||
/** Create `user_accounts` table if it doesn`t already exist */ | ||
@@ -120,3 +120,3 @@ await ezobjects.createTable(configUserAccount, db); | ||
*/ | ||
await anotherUserAccount.load(id, db); | ||
await anotherUserAccount.load(id, db, [`username`, `firstName`, `lastName`]); | ||
@@ -127,3 +127,3 @@ /** Log `anotherUserAccount` (should match last `userAccount`) */ | ||
/** Delete `anotherUserAccount` from the database */ | ||
await anotherUserAccount.delete(db); | ||
await anotherUserAccount.delete(db); | ||
} catch ( err ) { | ||
@@ -130,0 +130,0 @@ /** Cleanly log any errors */ |
const docket = require(`docket-parser`); | ||
docket.title(`EZ Objects v11.2.4`); | ||
docket.title(`EZ Objects v11.5.0`); | ||
docket.linkClass(`text-success`); | ||
docket.parseFiles([`index.js`]); | ||
docket.generateDocs(`docs`); |
{ | ||
"name": "ezobjects-mysql", | ||
"version": "11.2.4", | ||
"version": "11.5.0", | ||
"description": "Easy dynamic object generation with optional MySQL table linking", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# EZ Objects - MySQL Edition - v11.2.4 | ||
# EZ Objects - MySQL Edition - v11.5.0 | ||
@@ -60,3 +60,3 @@ EZ Objects (MySQL Edition) is a Node.js module (that can also be usefully [browserify](https://github.com/browserify/browserify)'d) that aims to save | ||
```javascript | ||
const ezobjects = require(`ezobjects-mysql`); | ||
const ezobjects = require(`ezobjects-mysql;`); | ||
const fs = require(`fs`); | ||
@@ -127,24 +127,24 @@ const mysql = require(`mysql-await`); | ||
/** | ||
* Create a new UserAccount called `userAccount`, initializing with | ||
* plain object passed to constructor. | ||
*/ | ||
const userAccount = new UserAccount({ | ||
username: `richlowe`, | ||
firstName: `Rich`, | ||
lastName: `Lowe`, | ||
checkingBalance: 4.32, | ||
permissions: [1, 3, 5], | ||
favoriteDay: new Date(`01-01-2018`) | ||
}); | ||
/** Let's use a self-executing async wrapper so we can await results */ | ||
(async () => { | ||
try { | ||
/** | ||
* Create a new UserAccount called `userAccount`, initializing with | ||
* plain object passed to constructor. | ||
*/ | ||
const userAccount = new UserAccount({ | ||
username: `richlowe`, | ||
firstName: `Rich`, | ||
lastName: `Lowe`, | ||
checkingBalance: 4.32, | ||
permissions: [1, 3, 5], | ||
favoriteDay: new Date(`01-01-2018`) | ||
}); | ||
/** | ||
* Test if `userAccount` is an instance of DatabaseRecord using | ||
* the included `instanceOf` helper function. | ||
*/ | ||
console.log(ezobjects.instanceOf(userAccount, `DatabaseRecord`)); | ||
/** | ||
* Test if `userAccount` is an instance of DatabaseRecord using | ||
* the included `instanceOf` helper function. | ||
*/ | ||
console.log(ezobjects.instanceOf(userAccount, `DatabaseRecord`)); | ||
/** Let's use a self-executing async function so we can await results */ | ||
(async () => { | ||
try { | ||
/** Create `user_accounts` table if it doesn`t already exist */ | ||
@@ -180,3 +180,3 @@ await ezobjects.createTable(configUserAccount, db); | ||
*/ | ||
await anotherUserAccount.load(id, db); | ||
await anotherUserAccount.load(id, db, [`username`, `firstName`, `lastName`]); | ||
@@ -187,3 +187,3 @@ /** Log `anotherUserAccount` (should match last `userAccount`) */ | ||
/** Delete `anotherUserAccount` from the database */ | ||
await anotherUserAccount.delete(db); | ||
await anotherUserAccount.delete(db); | ||
} catch ( err ) { | ||
@@ -220,9 +220,9 @@ /** Cleanly log any errors */ | ||
UserAccount { | ||
_id: 1, | ||
_id: 0, | ||
_username: `richlowe`, | ||
_firstName: `Richard`, | ||
_lastName: `Lowe`, | ||
_checkingBalance: 50.27, | ||
_permissions: [ 1, 3, 5 ], | ||
_favoriteDay: 2019-09-01T05:00:00.000Z } | ||
_checkingBalance: 0, | ||
_permissions: [], | ||
_favoriteDay: null } | ||
``` | ||
@@ -369,20 +369,28 @@ | ||
### MyObject.load(mysqlRow[, db]) | ||
### MyObject.load(mysqlRow[, db[, propertiesToInclude[, options]]])) | ||
* **Parameter:** mysqlRow `RowDataPacket` - A MySQL `RowDataPacket` returned as part of a MySQL result set | ||
* **Parameter:** db - `Object` | ||
* **Parameter:** db - `Object` - (optional) | ||
* **Parameter:** propertiesToInclude - `Array` - (optional) Properties to load (or not load if inverse option is used) | ||
* **Parameter:** options - `Object` - (optional) Desired options (currently just inverse = true/false) | ||
* **Description:** Load any configured properties from key/value pairs in `mysqlRow`. You can optionally pass the database `db` if you need it to be provided as a third argument to any loadTransform handlers defined for configured properties. | ||
### MyObject.load(obj[, db]) | ||
### MyObject.load(obj[, db,[ propertiesToInclude[, options]]])) | ||
* **Parameter:** obj Object | ||
* **Parameter:** db - `Object` | ||
* **Parameter:** db - `Object` - (optional) | ||
* **Parameter:** propertiesToInclude - `Array` - (optional) Properties to load (or not load if inverse option is used) | ||
* **Parameter:** options - `Object` - (optional) Desired options (currently just inverse = true/false) | ||
* **Description:** Load any configured properties from key/value pairs in `obj`. You can optionally pass the database `db` if you need it to be provided as a third argument to any loadTransform handlers defined for configured properties. | ||
### MyObject.load(id, db) | ||
### MyObject.load(id, db[, propertiesToInclude[, options]])) | ||
* **Parameter:** id number The value of the `id` property of the record you wish to load | ||
* **Parameter:** db - `Object` | ||
* **Parameter:** propertiesToInclude - `Array` - (optional) Properties to load (or not load if inverse option is used) | ||
* **Parameter:** options - `Object` - (optional) Desired options (currently just inverse = true/false) | ||
* **Description:** Load the record in database `db`, table `tableName`, that has its `id` field equal to provided `id` parameter. | ||
### MyObject.load(propertyValue, db) | ||
### MyObject.load(propertyValue, db[, propertiesToInclude[, options]]) | ||
* **Parameter:** propertyValue - `mixed` - The value of the `otherSearchProperty` property of the record you wish to load | ||
* **Parameter:** db - `Object` | ||
* **Parameter:** propertiesToInclude - `Array` - (optional) Properties to load (or not load if inverse option is used) | ||
* **Parameter:** options - `Object` - (optional) Desired options (currently just inverse = true/false) | ||
* **Description:** Load the record in database `db`, table `tableName`, that has its `otherSearchProperty` field equal to provided `propertyValue` parameter. Here, the actual field name of `otherSearchProperty` is provided in the object configuration, see the configuration section below. | ||
@@ -389,0 +397,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
816112
10610
846