C
C
c00ldev2020-01-11 15:21:05
MongoDB
c00ldev, 2020-01-11 15:21:05

How to disable showing __v in mongodb?

How can I disable showing versionKey and still cut the first image, i.e. to meet two conditions?

const conditions = {}
const projection = {
  images: { $slice: 1 },
  versionKey: false
}

Model.find(conditions, projection, options)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
ProAI, 2020-01-13
@ProAI

const MaxLimitImages = 1000; // Укажите максимальное количество возвращаемых изображений
const conditions = {
    images: { $slice: [1, MaxLimitImages] }
}
ModelName.find(conditions).select('-__v').exec( function(err, doc){
    if (err) {
         // Error
        console.log (err)
     } else {
         // Ok
         console.log (doc)
     }
 })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question