Answer the question
In order to leave comments, you need to log in
How to turn a collection into an array using mongoose?
In mongoDB, you can use toArray to turn a collection into an array and work with it, but how can you turn a mongoose model into an array?
Answer the question
In order to leave comments, you need to log in
Model in an array using mongoose - no way. An array of models, yes, an array of a model (essentially an ordinary object), no matter how. Think about what exactly you want to see in the array. If for example the model is {_id: ObjectId, Name: 'John', AGE: 22} then what is the array? Of course, you can convert an object into anything even in [ [_id, ObjectId], [Name, John], [AGE, 22] ], but this is by hand)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question