<NME> minutesFinder.js
<BEF> ADDFILE
<MSG> Introduce minutes finder service

Its purpose: it finds minutes, e.g.

 * all minutes of a given series
 * the last/first minutes of a given series
 * previous minutes
 * next minutes

 etc.

<DFF> @@ -0,0 +1,25 @@
+import { MeetingSeriesSchema } from '../collections/meetingseries.schema';
+import { MinutesSchema } from '../collections/minutes.schema';
+import { Minutes } from '../minutes';
+
+import { instanceCheck } from '../helpers/check';
+
+export class MinutesFinder {
+    static allMinutesOfMeetingSeries(meetingSeries, limit, descending = true) {
+        instanceCheck(meetingSeries, MeetingSeriesSchema);
+
+        const minutesIds = meetingSeries.minutes;
+        if (!Array.isArray(minutesIds) || minutesIds.length === 0) {
+            return [];
+        }
+
+        let sort = descending ? -1 : 1;
+        let options = {sort: {date: sort}};
+        if (limit) {
+            options.limit = limit;
+        }
+
+        return MinutesSchema.find({_id: {$in: minutesIds}}, options)
+            .map(m => new Minutes(m));
+    }
+}
\ No newline at end of file

{'addition_count': 25, 'commit_subject': 'Introduce minutes finder service', 'deletion_count': 0, 'file_extension': '.js', 'lang': 'js', 'license': 'mit', 'repo_name': '4minitz/4minitz'}