Hi all,
i have a database called Groups, where the name of the social groups is stored, and each record has a 'number of posts' field:
When i add a post in a group, let's say Passione Musica! (record 4), i want the relevant numberOfPosts value increased. I am using 'eq' to filter, but i don't know how to set the 'then' part:
wixData.query("Groups")
.eq("groupName", $w('#text50').text) // text50 is the text where the Group Name is written in the dynaic page
.find()
.then( (results) => {
..... //here goes the rest of the code
I guess i must use a R/W dataset to read the curent value and increase it.
Anyone can help?
Thank you as usual.
Hi Alessandro Demontis,,
Is this what you are trying to do???
When the button is clicked, the comment is.inserted to groupComents database.
Then the no. of post is inserted to the Group database..
For the first function you have already...
The second function, as I see, there is no need for insert but to update.... https://www.wix.com/corvid/reference/wix-data/update
You have to update the no.of post field....
Best reference https://www.wix.com/corvid/forum/community-discussion/typeerror-error-capturestacktrace-is-not-a-function?origin=member_posts_page
You got it write ->
var id var totalCount //under OnReady wixData.query("Groups") .eq("groupName", $w('#text50').text) .find() .then( (results) => { totalCount = results.totalCount; id1 = Number(totalCount) + 1 //submit button OnCick event $w('#submit').onClick((event) => { let toInsert = { "numberOfPosts": id1, }; });