Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!