A
A
Alexander Yakovlev2022-03-07 15:00:29
MongoDB
Alexander Yakovlev, 2022-03-07 15:00:29

How to store pages in mongodb?

I'm going to make an admin panel, but have not yet decided how it will work. I want to make one page of the site one collection - is it right to do this? Can you advise how to store website pages in mongodb?

I have only 3 pages: Home, Cart and Products

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Radiks Alijevs, 2022-03-07
@alexandr-web

The pages collection, which stores all the data about the pages, the output is like this:

{
     id: "dsfgwrgrwgrgertghert345y345wrg",
     title: "Главная",
     slug: "glavnaya",
     content: "Описание страницы"
}

For the cart, you need to create a separate collection that will store the products added by the user to the cart. But since you don't have registration, apparently the cart is some kind of non-standard one.
For the Products page, it's better to create your own Products collection:
{
     id: "dsfgwrgrwgrgertghert345y345wrg",
     title: "Товар 1",
     slug: "tovar-1",
     content: "Описание продукта",
    ... тут доп параметры продуктов
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question