Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
Best practice to store price changes over time in Mongodb

I'm using Nestjs and Mongoose as ODM. I have a model called Product which has the following properties:

Product Model

    @Schema({ timestamps: true, id:true, toJSON:{virtuals:true} })
    export class Product {
       @Prop({ required: true, type: String })
       title: string

       @Prop({ type: String })
       brand: string

       @Prop({ type: String })
       description: string


       @Prop({ type: Number})
       currentPrice: number

    }

every 4 hours product price will get updated. I'm wondering what's the best way to store product price history in MongoDB. in a SQL database like PostgreSQL, we make a ProductPrice table with (productId, price, date). But as MongoDB max document size is 16MB and thousands of products that I have& what is the best solution in MongoDB??

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is not challenging for MongoDB feel free and just create a ProductHistory collection for that:

{
  id: ObjectId,
  product_id: ObjectId,
  created_at: Date,
  price: 99,
  currency: "$",
  expiration: 4,
  expired: false
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda