D
D
DeniSidorenko2021-03-30 08:21:14
MongoDB
DeniSidorenko, 2021-03-30 08:21:14

How to get a given element from the database by ID?

Good afternoon, there is such a scheme for a collection of restaurants

const PointSchema = new mongoose.Schema({
  name: { type: String, required: true },
})

const RestaurantSchema = new mongoose.Schema({
  name: {
    type: String,
    require: true
  },
  description: {
    type: String,
    default: ""
  },
  image: {
    type: String,
  },
  rating: {
    type: String
  },
  sale: {
    type: String,
  },
  time: {
    type: String
  },
  minPrice: {
    type: String,
  },
  priceRange: {
    type: String
  },
  categories: [],
  points: [PointSchema]
})


Based on this, we get such a structure in Mongo
image.png
How can I get, for example, a Sushi Object from a Restaurant Object ( by ID )

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question