Hey, I started to use a database in my website and I would like to know if there is a way to count how many times a word (in my case a name) has been repeated in the database. For example I type the name John and add it to the database, the variable would show the number 1 and if I type John again, it would add another line of information but the number would turn 2 and so on…
Thanks for your time and hopefully it is actually possible xD
you can use this
wixData.query(“names”)
.eq(“title”, “john”)
.find()
.then( (results) => {
console.log(results.totalCount)
} )
Thanks for your reply,
I’m new to this language and I don’t really understand most of it, when I try to use you code it says that wixData isnt defined, I know that it’s a really simple thing but I have no idea how to fix it. And is there a way to look for repited names instead only of John?
@eusouosan befor onReady function you need to import the API
import wixData from “wix-data”;
Hm, ok it’s working now, but how can I add the number to a space on the database? And is it possible to compare to all the names on the database or just a specific one (in this case John)?
@eusouosan If you want to use a particular name you can just use a function(name). If you want to add items to the database check out the insert option https://www.wix.com/code/reference/wix-data.html#insert
@danieltanasec hey, thanks for your help but this code isn’t for me, I’m sticking to python and c# xD