So, I requested a specific document by id from mongoose. This document contains many elements. This list will always be very small (less than 10 items). I was wondering if there is a way to get a specific element from an array.
Example doc: { _id: 1, name: 'some name, items: [{ id: 23, name: 'item name 23' },{ id: 24, name: 'item name 24' }] }
From mongoose docs, I can get an array of elements:
doc.get('items')
From there I can iterate over the array and find what I want, which doesn't really matter. Just do not want to reinvent the wheel, if it is provided for in the framework.
source share