Hello I need help with this problem
this is my database
I add a repeater to my document member page to get document details for the current user
Without adding a filter it shows every member’s documents details here. When I add a filter like this
the repeater is not displaying any data. Can anyone help me to get details for the currently logged-in user?
I would say, that you are in the wrong forum, because this forum is dadicated to work with CODE.
If you want to solve your problem by using some code, then take a look here…
- First get the ID of the right USER…
https://www.wix.com/velo/reference/wix-users/currentuser
import wixUsers from 'wix-users';
$w.onReady(async function() {
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
console.log(user)
console.log(userId)
console.log(isLoggedIn)
user.getEmail()
.then((email) => {
let userEmail = email;
console.log(userEmail)
});
});
Now you have got some informations about the current user. What next?
Now you may want to search in your “Plan Documents”-DATABASE for entries belonging to the found user, right?
- Okey, then let’s switch to → “Wix-Data”…and so some data-query…
query - Velo API Reference - Wix.com
expanding the code…
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(async function() {
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
let myQuery = await wixData.query("Plan Documents")
console.log(user)
console.log(userId)
console.log(isLoggedIn)
user.getEmail()
.then((email) => {
let userEmail = email;
console.log(userEmail)
});
myQuery.eq("_id", userId)
.find()
.then((res)=>{
if(res.items.length>0){
console.log("Data found: ", res.items)
}
})
});
Take a look into CONSOLE, to see the results.
How to use CONSOLE ? → Press-F12 when using google-chrome and navigate to CONSOLE, or use the CONSOLE of the Preview-Mode in the Wix-Editor.