Answer the question
In order to leave comments, you need to log in
How to set schema for data structure in mongoose?
I decided to try writing REST on express and mongoose. There is a certain json that describes the prices for medicines in different parts of the city, I can’t figure out how to correctly set a scheme for it so that in the future it can be served by the CRUD type.
{
"region" : {
"Алатауский район": [
{
"drugs_id": "sdfds5562606dsf",
"max-price": 150,
"min-price": 130,
"date": "timestamp"
}
],
"Алмалинский район": [
{
"drugs_id": "sdfds5562606dsf",
"max-price": 165,
"min-price": 130,
"date": "timestamp"
}
]
}
}
const mongoose = require("mongoose")
const schema = mongoose.Schema({
region_id: String,
drug_id: String,
max_price: Number,
min_price: Number,
date: Date
})
module.exports = mongoose.model("Data", schema)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question