(async () => { try { let result = await feathersApp.logout(); console.log(‘the result is: ‘ + result) } catch (e) { console.log(e); } } ) () ;
(async () => let logoutResult = await feathersApp.logout(); console.log(logoutResult); })().catch(e => { console.log(e) });
https://stackoverflow.com/questions/70883305/best-way-to-make-a-knex-request-from-inside-a-promise
from grokling slack:
return sequelizeTable.create({‘column1’:‘data one’,‘column2’:‘data two’})
// Chain on .create
.then(result => sequelizeTable.count( { ‘where’ : { ‘id’ : result.id } } )
// Chain on .count
.then(count => console.log(count))
// Here we return result to be used after this
.then(() => result)
)
.then(result => console.log(result.id))
.catch(err => console.log(‘ERROR ‘ + err))
If you don’t want to make smaller functions to make your code more readable, you’d do it something like this:
return table.create(…..)
.then( result => {
return table.count( { ‘where’‘ : {‘id’: result.id }}));
.then (count => {
console.log(count));
return count;
})
.then (count => {
if ( count > 123 ) console.log(” > 123: “ + result.id) else
console.log ( “<= 123: “ + result.id );
return something;
})
})
.catch( …….)
NODE:
‘use strict’
/*
function connect() {
return new Promise( (resolve, reject) => {
client.rpc.make (‘promise’, ‘provide data passed in – abcde’, (err, reply) => {
resolve(reply)
});
})
}
connect()
.then( (result1) => { return(‘RESULT1: ‘ + result1); })
.then( (result2) => { return(‘RESULT2: ‘ + result2); })
.then( (result3) => { console.log(‘RESULT 3: ‘ + result3); })
;
*/
to load underscore (or any cdn) into javascript:
var cdn = ‘https://code.jquery.com/jquery-3.2.1.min.js’ ;
var cdn = “https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js” ;
var cdn=‘https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/2.1.2/deepstream.js’ ;
var jq = document.createElement(‘script’); jq.src=cdn;
document.getElementsByTagName(‘head’).appendChild(jq);
awesome way to use underscore to look up value in an object:
// _master is the object, sequelizeId is the index
console.log( _.findIndex(_master, (_tmpRow)=> { return _tmpRow.sequelizeId === ‘123456’ }) );
// 2017-09-26:
// https://stackoverflow.com/questions/37933445/underscore-js-find-object-which-contains-value-in-array
var master = [ { ‘name’ : ‘listOne’ , data : [ ‘nameOne’,‘nameTwo’] }
, { name: ‘listTwo’, ‘data’ : [ ‘nameThree’, ‘nameFour’ ] }
]
function findMe(myObj, myKey) {
var retVal=null;
_.each(myObj, (val)=> {
var byeBye = _.indexOf(val.data, myKey );
if ( _.indexOf(val.data, myKey ) > -1 ) {
retVal=val.name;
}
})
return retVal;
}
console.log( ‘RESULT: ‘ + findMe(master, ‘nameTwo’) )
1) FULL state name, no appreviation
2) organization name – no special characters
3) dont skip the “common name” – which is the domain name
openssl req -newkey rsa:2048 \
-keyout 800-language.com-WITH-PASSPHRASE.key \
-out 800-language.com.csr ;
Generating a 2048 bit RSA private key
…………………………………………………………………………….+++
…+++
writing new private key to ’800-language.com-WITH-PASSPHRASE.key’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
——-
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
——-
Country Name (2 letter code) [XX]:US
State or Province Name (full name) []:North Carolina
Locality Name (eg, city) [Default City]:Raleigh
Organization Name (eg, company) [Default Company Ltd]:800 Language
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server’s hostname) []:800-language.com
Email Address []:info@comptonpeslonline.com
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
CREATE TABLE `sequelizeTable` (
`sequelizeName` varchar(50) DEFAULT NULL,
`sequelizeAddress` varchar(50) DEFAULT NULL,
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`createdAt` date DEFAULT NULL,
`updatedAt` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
—
— Dumping data for table `sequelizeTable`
—
INSERT INTO `sequelizeTable` VALUES
( ‘lori edwards’ , ’948 south third street’ ,1 , ’2017-01-01’ , NULL )
, ( ‘mark edwards’ , ’123 swallow lane’ ,2 , ’2017-01-01’ , NULL )
, ( ‘marjorie edwards’ , ’7366 east ironwood court’ ,3 , ’2017-01-01’ , NULL )
;
const Sequelize = require(‘sequelize’);
const util = require(‘util’);
// mysql —host=localhost —user=jsonTestUser —password=jabberwolky exampleDb ;
var sequelize = new Sequelize(‘exampleDb’, ‘jsonTestUser’, ‘jabberwolky’, {
host: ‘localhost’,
dialect: ‘mariadb’,
pool: {
max: 5,
min: 0,
idle: 10000
}
});
// create table sequelizeTable ( sequelizeName VARCHAR, sequelizeAddress VARCHAR, id mediumint not null auto_increment, primary key (id) ) ;
var sequelizeTable = sequelize.define(‘sequelizeTable’, {
sequelizeName: {
type: Sequelize.STRING,
field: ‘sequelizeName’ // Will result in an attribute that is firstName when user facing but first_name in the database
},
sequelizeAddress: {
type: Sequelize.STRING
},
id: {
type: Sequelize.INTEGER,
primaryKey: true
}
}, {
freezeTableName: true // Model tableName will be the same as the model name
});
sequelizeTable.findAll({
where: {
id: 1,
sequelizeName: ‘lori edwards’
}
,order: [ ‘id’ ]
,attributes: [‘sequelizeName’,‘sequelizeAddress’,‘id’]
}).then( (returnedValue) => {
//console.log(
JSON.stringify(returnedValue ));
returnedValue.forEach ( © => {
var seconds = new Date() / 1000;
//console.dir(c.toJSON() );
console.dir(c.sequelizeName );
console.log(c.sequelizeAddress );
sequelizeTable.update(
{ sequelizeAddress : c.sequelizeAddress + ‘ ‘ + seconds } ,
{ where : { id: c.id } }
)
.then( (result) => {
console.log(result) ;
})
.catch( (err) => {
console.log(‘err: ‘ + err) ;
})
;
})
});
to rename comptonpesltrainers website login page , it is at the very BOTTOM Of the FIRST option settings page!
NOTE: this one (not in picture) is part of all-in-one-security.
————————————————————
Please enter an answer in digits:
thirteen + seven =
————————————————————-
also, see note at bottom about using ASH-recaptcha – it might have a conflict with all-in-1 security!
ASH-recaptcha did not work – use this one by Jorn Lund instead