Skip to content

Commit

Permalink
remove unused imports and warn about db errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chintannp committed Feb 17, 2022
1 parent 6a76400 commit 47f8274
Showing 1 changed file with 11 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { openDatabase, SQLResultSet, WebSQLDatabase } from 'expo-sqlite';
import { ConsoleLogger as Logger } from '@aws-amplify/core';
import { PersistentModel } from '@aws-amplify/datastore';
import { CommonSQLiteDatabase, ParameterizedStatement } from '../common/types';
import { table } from 'console';

const logger = new Logger('ExpoSQLiteDatabase');

Expand Down Expand Up @@ -48,29 +47,6 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
): Promise<T> {
const results: any[] = await this.getAll(statement, params);
return results.length > 0 ? results[0] : undefined;
/* const resultSet: SQLite.SQLResultSet = await new Promise(
(resolve, reject) => {
this.db.readTransaction(tx => {
tx.executeSql(
statement,
params,
(_, result) => resolve(result),
(_, err) => {
reject(err);
return true;
}
);
});
}
);
const result =
resultSet &&
resultSet.rows &&
resultSet.rows.length &&
resultSet.rows.item(0);
return result || undefined;
*/
}

public async getAll<T extends PersistentModel>(
Expand All @@ -85,8 +61,9 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
(_, res) => {
resolve(res);
},
(_, err) => {
reject(err);
(_, error) => {
reject(error);
logger.warn(error);
return true;
}
);
Expand All @@ -107,6 +84,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
() => resolve(null),
(_, error) => {
reject(error);
logger.warn(error);
return true;
}
);
Expand All @@ -130,6 +108,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
},
(_, error) => {
reject(error);
logger.warn(error);
return true;
}
);
Expand All @@ -149,6 +128,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
for (const [statement, params] of saveStatements) {
tx.executeSql(statement, params, null, (_, error) => {
reject(error);
logger.warn(error);
return true;
});
}
Expand All @@ -157,6 +137,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
for (const [statement, params] of deleteStatements) {
tx.executeSql(statement, params, null, (_, error) => {
reject(error);
logger.warn(error);
return true;
});
}
Expand Down Expand Up @@ -184,11 +165,13 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
},
(_, error) => {
reject(error);
logger.warn(error);
return true;
}
);
tx.executeSql(deleteStatement, deleteParams, null, (_, error) => {
reject(error);
logger.warn(error);
return true;
});
resolve(tempResults);
Expand All @@ -203,6 +186,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
for (const statement of statements) {
tx.executeSql(statement, [], null, (_, error) => {
reject(error);
logger.warn(error);
return true;
});
}
Expand Down Expand Up @@ -234,6 +218,7 @@ class ExpoSQLiteDatabase implements CommonSQLiteDatabase {
},
(_, error) => {
reject(error);
logger.warn(error);
return true;
}
);
Expand Down

0 comments on commit 47f8274

Please sign in to comment.