I need to add Aggregate Rating (review snippet) with stars to my Next JS weblog - javascript

I am new to React / Next JS. I have a blog based on Next JS template:
I have a lot of articles on my blog, and I would like to implement Schema Data to Next.js.
What is the best way to do it? As I understand, I need to store users' votes in a database to count average ratings?
There are several plugins for this, but I need to add Aggregate Rating with stars.


How to store product addons in Firestore DB?

So, I have a product saved to my Firestore DB, but I havent figure out how I can manage product addons, for example lets say the item was a pizza, and the person wanted extra cheese or extra tomatoes. Im not sure the best way to map this info in my DB. Lets say the following is my product entry (removed things like added timestamps for simplicities sake)
itemName (String)
itemBasePrice (number)
itemStock (number)
availableAt (array (of stores))
What is the best way for me to map product addons like extra cheese, or pepperoni, etc. should I make a DB entry for each addon? I feel like its expensive to make 100 calls from the DB to add one item to your basket?
Based on the description you provided, I think for this use case, nested fields or arrays should be the best option. I suggest you refer to this documentation and blog on how to structure data and use of arrays. If there is more information that needs to be tracked for each add ons, then you can consider using sub-collections. There are pros and cons for each way to structure the data. It really depends on how you are planning to use/query the data.

AWS most efficient way of finding datapoints with a particular tag (string value in a list)

I have a very newbie question on AWS. Let's say that I am running a store that offers 1.000.000 different products. Each of the products have their own row in dynamoDB in a table named products. Now I would like to attach a list of tags to each product for example ['football', 'outdoor', 'sport' ... ], so that when the customer searches for sport products with that tag shows up in the results.
I am thinking of the best way to approach this in order to offer fast but also cost-efficient searches, I have so far thought of 2 viable options:
Option 1: Include a tags field for each product that takes a list of tags.
'product_3' -> ['football', 'outdoor', 'sport']
Option 2: Create a new table where the key is each tag and includes a field that takes a list of products instead.
'sport' -> ['product_1', product_3, ... ]
I am inclined to go with option 2 since it feels like it will render the faster search, but I want to double check that I haven't made any wrong assumptions of missed any other superior option.
Would also be great to have an infrastructure that worked with word2vec so that products related to the search word also shows up, even if they are not identical string values.
DynamoDB is a powerful and very useful database, but it is not designed for search. My suggestion would be to use the correct tool for the job.
The pattern that I've used successfully multiple times is to use DynamoDB Streams and Lambda to replicate a table to an Elasticsearch index.
You can then have that string set of tags on each item in DynamoDB and manage them their. Your nominal read when you know the item hash key can be done against DynamoDB. When you want to search you hit Elasticsearch and get all of the benefit and flexibility it provides for searching. One of those benefits being really good pagination compared to DynamoDB's API as well as the ability to sort based on other attributes.

RESTful route structure of 3 related categories in Express/Node

I am a noob designing an API for an ecommerce site and I need to work out my restful route structure. We are basically using Node and React along with Express + GraphQL. I was wondering if someone could shine a light on the structure?
Here is what we Have:
It is a fashion store that has many products: skirts, blouses, tops, shirts, dresses, etc. You know the drill.
Each of these items will be in categories like this:
/dresses (GET all dresses)
/dresses/:id (GET a particular dress)
/skirts (GET all skirts)
/skirts/:id (GET a particular skirt)
In addition to all the products and the categories of products, at the top level we have DESIGNERS.
So, you would have a designer who has many categories, and each category has many products. Make sense?
I am puzzling over how to nest the express routes.
I want to do these things....
Get all designers
Get all categories a designer has a product in
Get all products a designer has in the store
Get an individual (:id) of a product a designer has.
by the same token I also want to ...
Get all categories.
Get all products in a category
Get and individual product (:id) in a category.
So we have a parent route (designers)
and then two child routes (I think) within designers which
are /categories, /categories/:id, and /categories/products, and /categories/products/:id
Could someone get me a code hint on creating the routes in express? I am wanting to create a JSON structure to render with this
You're essentially asking how to build out an entire REST framework for a backend, which is quite a lengthy thing to answer :)
I'd suggest you start by designing the structure of the JSON for all these objects. Here's a handy site that allows you to visually see the layout of the JSON: https://jsoneditoronline.org/
Once you've done that for all the objects you've mentioned, here's a good tutorial on how to build basic node.js endpoints: https://medium.com/#purposenigeria/build-a-restful-api-with-node-js-and-express-js-d7e59c7a3dfb

MongoDB create a new collection from the client side?

I have a collection of players in my app, this is built using a schema and then passing some stuff into my node.js configuration, perhaps it's a bit more complex than that but I mean this is the basic idea of how mongoDB for nodejs works with models and collections.
So now in my database I have my DB name then collections then a collection of players, great now I can build an api and start making requests to GET and PUT from that collection.
My problem is in my stats app after week one's game was tracked I need to clear all the player attributes so that in week 2 it's fresh, but I would like to save all the stats for the players from week 1.
So due to my basic knowledge of how a collection is built I am thinking in order to build a new collection I need to define a schema, but perhaps there is another way, if not then the schema would have to be dynamic right? Well how do I build a dynamic schema to suit this problem?
Idea: The user clicks a button saying complete week 1, then the server takes all the data from the players collection and builds a
new collection named week 1 players?
Question: If the above is a good idea, how do I build a function to create a new mongoDB collection and save players_week1 into its
own branch?
Final Word:
So hopefully someone has an optimal solution and understands what I am talking about, in the mean time I am going to try and follow my idea and see if I can search the docs to find some answers. Thanks guys.

Backendless : Relationship between tables issue and advice

Good evening,
I currently have 3 tables on my API at backendless.
**Users** (objectId, email, username, password)
**figures** (objectId, figure_name, figure_cat, figure_image, figure_info)
My figures data has rows kind of like a product.
Basically, I would like to link entries in the figures table to users but i'm not sure the best way to go about it.
I can create relationships of one-to-one and one-to-many but being new to that i'm not sure the best way to go about it.
Any help or advice would be much appreciated :)
does a user have many figures?
Can multiple users share the same Figure?
Assuming that a user has many figures, so you will have a userid column in the figures table (1:M rel between user->figures). I also assume your figure_cat is a relatively static list, so consider a lookup table for that so it has a fkey in the figures table as well. Also depending on the size of images, it may be better to put images in a different table so you can put them in a different file group.
Assuming figures are shared by users, you may need a M:N table in between users and figures that stores the userid, to figureid mapping (sometimes called a "tie table" I think)
What database are you using?
You can create a relationship between the tables either directly in the console or by making an API call where you save an object which references other (related) objects. See the documentation for details: http://backendless.com/documentation/data/js/data_relations.htm