sequelize example with findAll and update

Jan 12, 05:35 AM

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) ; }) ; }) });
Mark Edwards

,

---

wordpress captcha

Dec 27, 01:48 PM

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

Mark Edwards

,

---

Apache from scratch on Centos 7

Dec 23, 11:56 AM

NOTE: on google-cloud, dont forget to set firewall rules!

sudo yum —assumeyes update;
sudo yum —assumeyes install httpd;

sudo systemctl start httpd ;
sudo systemctl enable httpd ;
sudo systemctl status httpd ;

vi /etc/httpd/conf/httpd.conf ;
Find the section and change AllowOverride None to AllowOverride All

AllowOverride All

and add this line:

LoadModule rewrite_module modules/mod_rewrite.so

and finally:
sudo systemctl restart httpd ;

P H P — A P A C H E S T U F F :

yum —assumeyes install php-pdo ;
yum —assumeyes install php-pdo_mysql ;

service httpd restart ;

  1. had to do the following on 123systems.net:

yum —assumeyes install firewalld ;
systemctl unmask firewalld ;
systemctl enable firewalld ;
systemctl start firewalld ;
firewall-cmd —permanent —add-port=80/tcp ;
firewall-cmd —get-active-zones ;
firewall-cmd —zone=dmz —add-port=80/tcp —permanent ;
firewall-cmd —get-active-zones ;
firewall-cmd —reload ; ### do NOT forget this step !

  1. OPTIONAL OPTIONAL – otherwise you can see the “default” apache page
    cat </var/www/html/index.html ;
    this is a test to see if apache is indeed working
    END

now try the IP ## in your browser.

cat </var/www/html/phpinfo.php;

END

  1. INSTALL PHP:

yum —assumeyes install php php-pear php-mysql ; ## current default centos version, might be old
systemctl restart httpd.service ; ## dont skip this step (again)!

Mark Edwards

,

---

cgi-node

Dec 13, 07:52 AM

NOTICE CASE – instructions are WRONG. CgiNodeInfo() not cgiNodeInfo() !

Mark Edwards

,

---

mariadb 10.2 beta deepstream installation

Dec 12, 05:35 AM

mariadb 10.2 BETA written from here

INITIAL:

sudo yum —assumeyes update ;
sudo yum —assumeyes group install “Development Tools” ;
sudo yum —assumeyes install git wget curl ;
###########sudo yum —assumeyes install gcc gcc-c++ ;

NODE:

sudo -i ;
curl —silent —location https://rpm.nodesource.com/setup_7.x | bash – ;
yum —assumeyes install nodejs ;
which node ;
node —version ;

APACHE:

sudo yum —assumeyes install httpd ;
sudo systemctl start httpd.service ;
sudo systemctl enable httpd.service ;

MARIADB:

cat </etc/yum.repos.d/MariaDB.repo ;

  1. MariaDB 10.2 CentOS repository list – created 2016-12-12 17:34 UTC
  2. http://downloads.mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.2/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    END

yum —assumeyes install MariaDB-server MariaDB-client ;

mysql_install_db —user=mysql —basedir=/usr —datadir=/var/lib/mysql ;
systemctl start mariadb ;
systemctl enable mariadb ; ## optional !

mysql ; ## notice version number !
CREATE USER ‘john’@‘localhost’ IDENTIFIED BY ‘123’ ;
GRANT ALL ON . to ‘john’@‘localhost’ IDENTIFIED BY ‘123’ with max_queries_per_hour 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
CREATE DATABASE IF NOT EXISTS deepstream ;
GRANT ALL PRIVILEGES ON `deepstream`.* TO ‘john’@‘localhost’ ;
EXIT

mysql —user=john -p123 deepstream ;

DEEPSTREAM:

sudo wget https://bintray.com/deepstreamio/rpm/rpm -O /etc/yum.repos.d/bintray-deepstreamio-rpm.repo ;
sudo yum install —assumeyes deepstream.io ;
which deepstream;
deepstream —version ;

DEEPSTREAM-MARIADB CONNECTOR:

MANUALLY INSTALL plugin at /etc/deepstream/config.yml !
plugins: storage: name: deepstream.io-storage-mariadb options: ds_host: ‘localhost’ ds_user: ‘john’ ds_password: ‘123’ ds_databaseName: ‘deepstream’ ds_tableName: ‘deepstream_storage’ ds_keyType: ‘text’ ds_valueType: ‘text’ ds_splitter: ‘/’

(log out of root!)

mkdir server; cd server;

npm init;
npm install —save uws ; ## not sure if this is needed??
npm install —save deepstream.io ;
npm install —save deepstream.io-client-js ;
npm install —save perimetral/deepstream.io-storage-mariadb ; ## may be replaced
npm install —save dyncol ; ## only for blob/binary usage
npm install —save sequelize ; ## only for blob/binary usage

server.js:

cat <server.js ;
let ds = require(‘deepstream.io’);
let connector = require(‘deepstream.io-storage-mariadb’);
//let server = new Deepstream(); ### BAD – typo in instructions !
let server = new ds();

server.set(‘storage’, new connector({ mariasql: { host: ’127.0.0.1’, user: ‘john’, password: ‘123’, db: ‘deepstream’, }, table: { name: ‘deepstream_storage’, keyType: ‘text’, valueType: ‘text’, }, splitter: ‘/’,
}));

server.start() ;
END

node server.js ;

===================

example.js

mkdir ~/example; cd ~/example ;
npm init; ## answer questions
npm install —save deepstream.io-client-js ;

cat < example.js ;

const deepstream = require(‘deepstream.io-client-js’) ;
const util = require(‘util’) ;
const dsIpPort = ‘localhost:6020’ ;
const client = deepstream(dsIpPort).login() ;

var record = client.record.getRecord(‘Another-New-Record-Name’);

var testJson = { ‘newTestJson’ : [ { ‘firstKey’ : ‘this is my first key’ , ‘secondKey’ : ‘this is my second key’ } , { ‘thirdKey’ : ‘this is my third key’ , ‘fourthKey’ : ‘this is my fourth key’ } ] } ;

console.log(util.inspect(testJson));

record.whenReady( () => { // ? ? ? ? ? ? record.set(‘myTestJsonValue’, {x:2} ); //record.set(‘firstname’, ‘this is a test value’ ); //record.set(‘myTestJsonValue’, testJson );
});
END

node example.js ;

#######deepstream install storage mariadb ;

  1. ln -s
  2. /var/lib/deepstream/deepstream.io-storage-mariadb/src/connector.js
  3. /var/lib/deepstream/deepstream.io-storage-deepstream.io-storage-mariadb ;


https://www.npmjs.com/package/deepstream.io-storage-mariadb
===

##git clone https://github.com/perimetral/deepstream.io-storage-mariadb

  1. ?? ln -s /root/node_modules/deepstream.io-storage-cockroachdb/src/connector.js

Mark Edwards

,

---

« Older Newer »

Manage