How to implementing a Query for User Article 'Essence' Counts and Sorting #4667
-
|
Overview Background Desired Solution Query Construction: How can I construct a query to tally the number of 'essence' marks for articles by each user? Methods Tried |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
#4619 I found a question similar for statistics, but it did not receive the expected answer |
Beta Was this translation helpful? Give feedback.
-
|
There is no universal solution or "direct guidance" as it would depends on your actual data structure and destired access patterns. I'm not entire sure that I understand what "essense" means and how it is used in the above context, but if we assume that it serves the same purpose as "likes", then one possible approach could be (I haven't tested it, treat it just as suggestion/pseudo-code):
Then you can query the above const result = await pb.collection("articlesStats").getFullList({
expand: "article", // optional if you want the "articles" record to be included in the json
})
// fetch the stats only for a specific article
const result = await pb.collection("articlesStats").getOne("ARTICLE_ID")If you need further help, please provide more details about your actual collections structure (you can export your collections configuration from the Admin UI > Settings > Export collections) and the desired behavior (sample data output can also help). |
Beta Was this translation helpful? Give feedback.
There is no universal solution or "direct guidance" as it would depends on your actual data structure and destired access patterns.
I'm not entire sure that I understand what "essense" means and how it is used in the above context, but if we assume that it serves the same purpose as "likes", then one possible approach could be (I haven't tested it, treat it just as suggestion/pseudo-code):
Create a new
articlesEssences/articlesLikescollection that will contain relation with the user who marked the article as "essense"/"liked". The collection shema could be:relationfield to the "users" collectionrelationfield to the "articles" co…