Userdaten in db einfügen, user suchfunktion
This commit is contained in:
@ -4,9 +4,9 @@ const stringSimilarity = require('string-similarity');
|
||||
|
||||
//Create User Info
|
||||
|
||||
async function updateUser(uid, mid) {
|
||||
async function updateUser(uid, mid, name, picture, email) {
|
||||
try {
|
||||
await nonQuery('INSERT INTO "User" (username, message_id) VALUES ($1, $2);', [uid, mid]);
|
||||
await nonQuery('INSERT INTO "User" (username, message_id, name, picture, email) VALUES ($1, $2, $3, $4, $5);', [uid, mid, name, picture, email]);
|
||||
|
||||
}
|
||||
|
||||
@ -28,6 +28,22 @@ async function getmessageids(sl_id) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function searchUsers(searchstring) {
|
||||
try {
|
||||
let users = await query('SELECT row_to_json("User") AS obj FROM "User";');
|
||||
return users.filter(function(obj) {return obj.name.toUpperCase().includes(searchstring.toUpperCase())});
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//SELECT own shopping lists
|
||||
async function getShoppinglistsAdmin(username) {
|
||||
try {
|
||||
@ -534,5 +550,5 @@ function probability(cur_item, data) {
|
||||
module.exports = {
|
||||
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
|
||||
moveDoneItems, getDonePurchases, getShoppinglistsByLink
|
||||
moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers
|
||||
}
|
||||
|
Reference in New Issue
Block a user