Skip to content
Snippets Groups Projects
Commit 372cceea authored by Erkan Karabulut's avatar Erkan Karabulut
Browse files

fix lint errors in Neo4jAdapter class

parent bc4832b5
No related branches found
No related tags found
No related merge requests found
......@@ -41,28 +41,28 @@ export class Neo4jAdapter extends DbAdapterBase {
async initDatabase(dbInfo: DbConnectionInfo) {
// check if the given db exists
let database = await this.runQuery(
'show databases where name=$db_name', {
"show databases where name=$db_name", {
db_name: dbInfo.connectionOptions.NEO4J_DATABASE
}
)
if (database == false) {
let create_db = this.createDatabase(dbInfo.connectionOptions.NEO4J_DATABASE);
if (!create_db) {
let createDb = this.createDatabase(dbInfo.connectionOptions.NEO4J_DATABASE);
if (!createDb) {
NodeUtils.logError("Neo4J database creation is failed! Exiting...");
process.exit(1);
}
}
let user = await this.runQuery(
'show users where user=$username', {
"show users where user=$username", {
username: dbInfo.connectionOptions.NEO4J_USERNAME
}
);
if (!user) {
let create_user = this.createUser(dbInfo.connectionOptions.NEO4J_USERNAME, dbInfo.connectionOptions.NEO4J_PASSWORD);
if (!create_user) {
let createUser = this.createUser(dbInfo.connectionOptions.NEO4J_USERNAME, dbInfo.connectionOptions.NEO4J_PASSWORD);
if (!createUser) {
NodeUtils.logError("Couldn't create the db user! Exiting...");
process.exit(1);
}
......@@ -87,26 +87,26 @@ export class Neo4jAdapter extends DbAdapterBase {
}
async createIndexes() {
await this.runQuery(`CREATE INDEX index_sensor_objectId IF NOT EXISTS FOR (s:Sensor) ON (s.objectId)`, {});
await this.runQuery(`CREATE INDEX index_thing_objectId IF NOT EXISTS FOR (t:Thing) ON (t.objectId)`, {});
await this.runQuery("CREATE INDEX index_sensor_objectId IF NOT EXISTS FOR (s:Sensor) ON (s.objectId)", {});
await this.runQuery("CREATE INDEX index_thing_objectId IF NOT EXISTS FOR (t:Thing) ON (t.objectId)", {});
}
/**
* Create a database with the given name
* @param db_name
* @param dbName
*/
async createDatabase(db_name) {
async createDatabase(dbName) {
let result = await this.runQuery(
'create database $dbname', {
db_name: db_name
"create database $dbName", {
dbName: dbName
}
)
/* TODO: We don't know what result returns in case of success.
Because only enterprise version of Neo4j allows creation of a new database
In case we use the enterprise version, check if the db created successfully
*/
if (!result) {
/* TODO: We don't know what result returns in case of success.
Because only enterprise version of Neo4j allows creation of a new database
In case we use the enterprise version, check if the db created successfully
*/
}
return true;
......@@ -114,22 +114,18 @@ export class Neo4jAdapter extends DbAdapterBase {
/**
* Create a user with the given username and password
* @param db_user
* @param db_user_password
* @param dbUser
* @param dbPassword
*/
async createUser(db_user, db_user_password) {
async createUser(dbUser, dbPassword) {
let result = await this.runQuery(
'CREATE USER $user SET PASSWORD $password', {
user: db_user,
password: db_user_password
"CREATE USER $user SET PASSWORD $password", {
user: dbUser,
password: dbPassword
}
)
if (!result) {
return false;
}
return true;
return result;
}
/**
......
......@@ -105,7 +105,6 @@ class Updates extends React.Component {
"min": min,
"max": max,
"currently": lastOne
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment