Hi
I am creating my own web app connecting through databases and dynamic pages.
What I need is when a user A comments on user B’s post then he should get the notification about it, but I’m missing the logic behind that. How to achieve it?
Thanks in advance
If you have a database of ‘messages’ then you can do the following →
- Add a field called ‘status’.
- When the user inserts message to the database, the status should be ‘wait’.
- In the home page of the user, query the filed ‘‘status’’ of ‘‘message’’ database.
- Return all the items that matches ‘wait’
Eg: for query →
wixData.query("messages") //database
.eq("status", "wait") //field name and value
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
let totalCount = results.totalCount; // get the total
count of messages, the user haven't seen yet
} else {
console.log("No messages yet!!");
}
} );
Then on the dynamic page (or normal page) of notifications.
If you have a repeater you can query exactly like above →
wixData.query("messages") //database
.eq("status", "wait") //field name and value
.find()
.then( (results) => {
if(results.items.length > 0) {
let items = results.items;
$w('#repeater1').data = items;
} else {
console.log("No messages yet!!");
}
} );
Woww. Thanks for answering this But I got 70% of you. Can you please provide us a YouTube video if you can. It would be great
@iamabhaysalvi Please u nderstand that this forum is a community of Corvid developers and users where various topics are discussed and information shared. It is not a support site. The members of the forum have their own work to do and can’t be expected to supply a full code solution or a video tutorial.
To learn about programming with Corvid, read the following articles that will help you start working with Corvid:
-
About Corvid by Wix - what Corvid is and what features it has.
-
Getting Started with Corvid by Wix - step-by-step tutorial on how to start using Corvid.
-
Onboarding to Corvid by Wix - introduction to Corvid with short tutorials.
If you find that you are having difficulty with code and need assistance, you may want to check out the Wix Marketplace - it’s a place where you can look for Corvid experts for hire.
@yisrael-wix man you are unbearable! It doesn’t teach anything, it only complains … This is a knowledge exchange community. If you can’t contribute, help, it doesn’t hurt. Bad mood, without sorority, without humility. Every post I see has a comment from you. It should be banned.