Sequelize Deprecated Error Message when running migration - javascript

Hello guys Im beginner in Sequelize and Node js,
I have read their offical docs, read their github, searched blog post and couldnt solve it.
Im constantly getting warning messages :
GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:236:13
This error is only happening when running migrations but this is not happening when Im starting server normally
Herei is my connection.js file
https://pastebin.com/5NKfExib

So I googled for few days and here is the answer:
operator alliases must be set to false when connecting to database like this:
sequelize = new Sequelize(config.database, config.username, config.password, Object.assign({}, config, {
pool: dbConst.pool,
operatorsAliases: false,
})
Also in migrations.config.json, operatorAliases must be set to false
And in your code always use Sequalize.Op

Related

MongooseServerSelectionError: connect ETIMEDOUT 13.250.154.115:27017

While I'm working on my school project, This error just randomly showed up.
Error connecting to MongoDB: MongooseServerSelectionError: connect ETIMEDOUT 13.250.154.115:27017
even in the compass is not working, I tried to run my other project that has a MongoDB connection and they are all inputting the same error
I tried to search it before asking this. this is what I already did
-terminating cluster and creating new
-check the IP address in network access and it's in public
-restart my laptop
-creating a new MongoDB account
-doubled check the URI
enter image description here
enter image description here
is there having the same problem as me that is being solved?
btw I'm using mern stack
try this :
mongoose.connect(process.env.MONGO_URI,{ useNewUrlParser: true, useUnifiedTopology: true });
In order to better understand these options, I strongly recommend you to read the Mongoose documentation about the deprecation warnings.
https://mongoosejs.com/docs/5.x/docs/deprecations.html

Sequelize dialect dependency on msnodesqlv8

We are using sequelize package to connect to mssql server. Our backend code is in javascript.
We have a working code like below:
const sequelize = new Sequelize({
logging:log,
dialect:'mssql',
dialectModulePath: 'msnodesqlv8/lib/sequelize'
dialectOptions:{
connectionString: process.env.connectionString,
encrypt: false
},
operatorAliases: false
})
Below is the format of connectionString we are using in above snippet:
Driver={ODBC Driver 17 for SQL Server}; Server=<<Servername>>;Database=<<Database>>;Trusted_Connection=yes;
And in package.json I can see below 3 packages:
"msnodesqlv8":"^2.4.7",
"sequelize":"^4.41.2",
"sequelize-msnodesqlv8":"^0.2.6-beta.8"
In official doc of sequelize, I can see
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect:'mssql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},
// SQLite only
storage: 'path/to/database.sqlite'
});
There is no mention about msnodesqlv8. Right now connection is working fine. But I was just trying to understand if sequelize uses tedious under the hood in order to have appropriate drivers so that connection to DB can be made. Then what is the use of msnodesqlv8?
In msnodesqlv8 official docs I can see it has some enhanced security features.
What I am trying to achieve by understanding this?
I want to remove the dependency of my code from msnodesqlv8 and snippet provided in official document of sequelize for mssql is not working for me.
Reason for removing dependency of msnodesqlv8?
We are migrating code to linux and msnodesqlv8 is compatible with linux which has dependency on msodbcsql17 driver which needs to be installed separately.
After going to the pain of switching to the msnodesqlv8 driver today, I felt like I should comment on this... unfortunately my rep isn't high enough to comment so you get an answer instead :)
You're correct, many people seem to be using the msnodesqlv8 driver for the integrated security aspects.
I does have a dependency on msodbcsql17 (be sure not to try msodbcsql18). And this dependency is a pain to get in place. Word of warning.. trying to use it in a debian based docker image results in segfaults. We switched to alpine based and the segfaults cleared up.
What I haven't seen mentioned anywhere is the significant performance improvement you get from using msnodesqlv8. Small example, we have a simple query (takes .3 seconds to execute and another .3 to return 29000 <1kb rows using the JDBC driver) that would take 58 seconds using tedious. That was using tedious directly (not through sequelize or mssql for node). Almost all of that time was it reading the result stream. Switching to msnodesqlv8 reduced the time to under 2 seconds.
Summary: Pain to install. Much better performance for some workloads.

App is not connecting to the mongodb Atlas

I start learning JavaScript on the freecodecamp and stuck on a challenge.
The challenge itself is to setup a mongoose.
But every time I am submitting my answer it giving me an error of "mongoose should be connected to a database.
I checked the fcc forum on the same topic and all of the solutions not working for me
The challenge provide the starting code and all what is required is to setup mongo atlas and connect your app to it
In the app.js you should add
require("dotenv").config();
let mongoose = require("mongoose");
mongoose.connect(process.env.MONGO_URI, {
useUnifiedTopology: true,
useNewUrlParser: true
});
in the .env file
MONGO_URI=mongodb+srv://userName:password#cluster0.rmycu.mongodb.net/myFirstDatabase
Where the userName and password are changed to mine without any prohibited symbols.
You should also add this dependencies to package.json
"mongodb": "4.1.1",
"mongoose": "6.0.5"
Any help appreciated
Can you try to change connection config and use it without additional options:
mongoose.connect(process.env.MONGO_URI);
Since you are using Mongoose version higher than 6.0, these options are not available as config anymore, and are configured automatically.

Node.JS MySql Module - Cannot Connect to Any Database - ECONNRESET

I'm trying to use the mysql module to connect to my database. But everytime, I get the following error: read eCONNRESET There is problem. (Note, that last part is from my console log. See below.)
I don't think this is a problem with database security settings. I've been trying to connect to my new database (hosted on AWS) for the last several days with no luck. Then, just now I attempted to connect to an Azure database that has been running smoothly for a couple years. Same problem: read eCONNRESET.
By the way, if I randomly change the host string to something invalid, my code returns an error saying the host wasn't found. So that tells me it's working to some extent.
I'm very new to the coding world and need all the help I can get.
Here's my code:
console.log('starting Launch');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : '....windows.net',
user : 'test',
password : 'test',
port : '1433'
})
console.log('step2')
connection.connect(function (err) {
if (!err)
console.log("conncetd");
else
console.log(err + "There is problem");
});
Copy full error message.
Check connectivity to your DB instance, use nmap (linux) or telnet (windows). If you can't reach host - check your local machine and server firewall, restrictions. If you can, go to 2.
Try to use different MySQL client, MySQL WorkBench, HeidiSQL, DBeaver.
If you can't - than something wrong with MySQL configuration. If you can, go to 3.
Copy info about: OS, node version, mysql module version.
you could try
mysql.createPool({});
instead of
mysql.createConnection({})

I need to create a simple database for use in an Angular/Node demo. What is the path of least resistance to adding such a database to my demo?

I need to create a simple database for use in an Angular/Node demo. What is the path of least resistance to adding such a database to my demo?
Incidentally, I cannot use the MEAN stack.
Edit: I failed to mention that I'm running the demo from my local environment--from my laptop.
The path of least resistance would be to use Sequelize and sqlite3 in your application.
Start off by running npm install sequelize sqlite3.
Then in your code
var Sequelize = require( 'sequelize' )
var connection = Sequelize.connect( undefined, {
dialect: 'sqlite',
storage: __dirname + '/db.sqlite'
})
Tada, you have a database connection syncing to a local sqlite DB.
You'll likely need to consult the Sequelize documentation to use this connection.
If, however, you wanted an API for your angular demo, json-server is what you're looking for.

Categories

Resources