Answer the question
In order to leave comments, you need to log in
How to set a limit in working with arrays in a database (mongoose)?
In general, here is the circuit and the controller, the task is this. It is
necessary to set a limit on renting books, and if there are more than 3 books, then the boolean type becomes false, (it is commented out because the node was cursing, I decided to figure it out later, but I will be glad if they tell me here too)
tried limit() didn't work, doesn't work with findByIdAndUpdate(), tried ternary, if els, doesn't work either.. googled, didn't find anything like that
Answer the question
In order to leave comments, you need to log in
I'll start a little off the point of the question, but it will also come in handy for you.
Clients
, but Client
. We use plurals when talking about an array. You are creating a model of one client, not several.isBlocked
- useless field. And it swears, because the class is waiting Boolean
, and you are passing the type.$push
of .404
. $addToSet
, otherwise you throw it away Bad Request
or something like that. arr.push
on the document and the subsequent one save
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question