Now save only the username of the user in search history.

This commit is contained in:
2018-03-06 19:27:18 +01:00
parent 7c4aeb48ab
commit aa0094762b

View File

@@ -15,7 +15,7 @@ class SearchHistory {
* @returns {Promise} * @returns {Promise}
*/ */
read(user) { read(user) {
return this.database.all(this.queries.read, user) return this.database.all(this.queries.read, user.username)
.then(rows => rows.map(row => row.search_query)); .then(rows => rows.map(row => row.search_query));
} }
@@ -26,7 +26,7 @@ class SearchHistory {
* @returns {Promise} * @returns {Promise}
*/ */
create(user, searchQuery) { create(user, searchQuery) {
return this.database.run(this.queries.create, [searchQuery, user]) return this.database.run(this.queries.create, [searchQuery, user.username])
.catch((error) => { .catch((error) => {
if (error.message.includes('FOREIGN')) { if (error.message.includes('FOREIGN')) {
throw new Error('Could not create search history.'); throw new Error('Could not create search history.');