Nodejs and Orientdb database connection? - node.js

I am new to Orientdb and I am looking to know more about how I can use nodejs with orientdb. Any sites , suggestions , videos will be helpful .. Thanks

You can find some examples in the OrientDB official documentation: https://orientdb.com/docs/2.2/OrientJS.html#orientjs-driver
Anyway, this is an example of connection:
var OrientDB = require('orientjs');
var server = OrientDB({
host: 'localhost',
port: 2424,
username: 'root',
password: 'root'
});
var db = server.use({
name: 'GratefulDeadConcerts',
username: 'root',
password: 'root'
});
server.close();
Hope it helps
Regards

Related

no pg_hba.conf entry for host \"IP-ADDRESS", user \"username\", database \"database\", SSL off

I am using Digitalocean managed PostgreSQL and trying to access the database from node.js (using pg-promise) which is a Google Cloud Function.
no pg_hba.conf entry for host "IP-ADDRESS", user "username", database "database", SSL off
Below is my db config
import * as pgPromise from 'pg-promise';
const dbConfig = {
username: 'username',
password: 'password',
host: 'host string',
port: PORTNUMBER,
database: 'database',
sslmode: 'require'
};
const pgp = pgPromise({});
const db = pgp(dbConfig);
export { db, pgp };
How to fix this? Please advise.

How to configure the value for pg_stat_activity.application_name from within a Node.JS application

I wish to know if there is any way of supplying a value for pg_stat_activity.application_name from a Node.js application.
Example: nodejs myapp.js will show: NodeJs - My App
Just as a_horse_with_no_name suggested, putting application_name when you are creating your connection works like a charm in this way:
const client = new Client({
user: 'postgres',
host: 'localhost',
database: 'dbname',
password: 'postgres',
port: 5432,
application_name: 'a name', <---- THIS ONE MAKES THE MAGIC :)
});
So many thanks!

Heroku postgres database not connecting

I'm playing around on Heroku and trying to link to a postgres DB. My app is linked directly to the github source code. When I run it locally with the Heroku DB credentials and with npm start it works, but not when it is deployed, I've got this error:
{"name":"SequelizeConnectionError","message":"password authentication failed for user \"riunhwzbjuwwgw\"","parent":
{"name":"error","length":103,"severity":"FATAL","code":"28P01","file":"auth.c","line":"285","routine":"auth_failed"},"original":
{"name":"error","length":103,"severity":"FATAL","code":"28P01","file":"auth.c","line":"285","routine":"auth_failed"}}
Any ideas at all?
Edit : here's the connection
var sequelize = new Sequelize(config.db.dbName, config.db.username, config.db.password, {
host: config.db.host,
dialect: config.db.dialect,
port: config.db.port,
dialectOptions: {
ssl: true
},
logging : false
});
and my variables
db: {
dbName: process.env.DBNAME,
username : process.env.DBUSER,
password : process.env.DBPASSWORD,
host : process.env.DBHOST,
dialect: "postgres",
port : 5432
}
Like I said, it works locally. The password is set like the DBUSER riunhwzbjuwwgw, could it be something those slashes? \"riunhwzbjuwwgw\"

node.js mysql client undefined

I'm trying to create a mysql database to node.js server. I've installed mysql module through command prompt:
npm install mysql
Then I execute the following code:
var Client = require('mysql').Client;
console.log(Client);
Console display undefined. That is, Client is undefined. Please tell me why it is undefined?
I'm following this tutorial
http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/
Maybe the the tutorial is a little bit old. Just use the instruction on the node-mysql docs:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret'
});
connection.connect();
And you should be able to connect to your MySQL database.
The node js APIs having been changing updating a lot in recent past, so it is highly possible that the tutorial you have been following is out of date according to the version you are using. You can follow the code example here I am updating or you may refer to something else, the only part that matters is it should work at minimum cost.
var mysql = require('mysql');
app.use( connection(mysql, {
host: 'myhost',
user: 'user_name',
password: 'password',
port: 3306, //port mysql
database: 'database_name',
multipleStatements: 'true' //false by default
}, 'pool'));
req.getConnection(function(err, connection) {
connection.query("SELECT * FROM `table_name`;",function (error,row){
if(!error){
//do something.....
}
else console.log("Error : "+err);
});
//do something else...
});
Thank you...!

sequelize-postgres Error code 91

If you use sequelize as your ORM with postgres database, you may see this error code, especially for first-timer, including me. Found out the problem from this discussion .
Just define the 'port' property with 5432 (default postgres port) will fix the problem.
var orm = new sequelize('database', 'user', 'password', {
dialect: 'postgres',
host: 'localhost',
port: '5432' /* define database port */
});

Resources